Skip to content

Instantly share code, notes, and snippets.

@JulianMiller
Created March 1, 2012 05:00
Show Gist options
  • Save JulianMiller/1947413 to your computer and use it in GitHub Desktop.
Save JulianMiller/1947413 to your computer and use it in GitHub Desktop.
omniauth = session["devise.omnidata"]
@user.username = omniauth['info']['first_name']+omniauth['info']['last_name']
@user.pic_url = omniauth['info']['image']
#From the facebook graph api docs: use ?type=square | small | normal | large to request a different photo
@user.pic = rails_download_url_method(@user.pic_url?square | small | normal | large)
require 'open-uri'
open('image.png', 'wb') do |file|
file << open('http://example.com/image.png').read
end
a cleaner way might be directly in the method
def has_avatar
blah blah blah
data = open('http://penis.com/micropenis.jpg
blah blah save
end
def get_avatar(omniauth)
@user.pic = open(omniauth['info']['image']).read
#use paperclip to save image
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment