Skip to content

Instantly share code, notes, and snippets.

@andrewwho
Created June 21, 2012 17:54
Show Gist options
  • Save andrewwho/2967354 to your computer and use it in GitHub Desktop.
Save andrewwho/2967354 to your computer and use it in GitHub Desktop.
hurray
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)
if !u.authentications.blank?
# grab the image from facebook and store it in the cloud.
# remote_picture_url
# "https://graph.facebook.com/"+auth.uid+"/picture?type=small"
auth = u.authentications.find_by_provider('facebook')
u.remote_image_url = "https://graph.facebook.com/"+auth.uid+"/picture?type=large"
u.save!
else
puts u.username + " does not have facebook!"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment