-
-
Save jlogsdon/2967486 to your computer and use it in GitHub Desktop.
hurray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
def fetch_facebook_image | |
return false if authentications.blank? | |
auth = authentications.find_by_provider('facebook') | |
self.remote_image_url = "https://graph.facebook.com/"+auth.uid+"/picture?type=large" | |
self.save | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :images do | |
desc "populating user.image" | |
task :pull => :environment do | |
print "This task will pull FB images into user.image if user has fb authentications. Confirm? [y/n]: " | |
answer = $stdin.gets.chomp() | |
if answer == 'y' | |
# User.all.each do |u| | |
u = User.find(50) | |
begin | |
if u.fetch_facebook_image | |
puts "#{u.username}'s image has been fetched!" | |
else | |
puts "#{u.username} is not authenticated." | |
end | |
rescue => e | |
puts "There was an error updating #{u.username}: #{e.message}" | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment