Advertisement
Guest User

Untitled

a guest
Jul 31st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. class TagsController < ApplicationController
  2.  
  3. def index
  4. @tags = Tags.find(:all, :order => "count DESC")
  5. end
  6.  
  7. def update
  8. @user = "..."
  9. @pass = "..."
  10. @path = "/v1/tags/get"
  11.  
  12. http = Net::HTTP.new('api.del.icio.us', 443)
  13. http.use_ssl = true
  14. http.start { |http|
  15. req = Net::HTTP::Get.new(@path, {'User-Agent' => 'PecK AF83IsDelicious 0.2'})
  16. req.basic_auth('@user', '@pass')
  17. @xml = http.request(req).body
  18. }
  19. REXML::Document.new(@xml).elements.each('tags/tag') do |element|
  20. @t = Tags.new
  21. @t.count = element.attributes['count']
  22. @t.tag = element.attributes['tag']
  23. @t.save
  24. end
  25.  
  26. redirect_to(:action => 'index')
  27. end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement