Created
June 17, 2012 08:20
-
-
Save joker1007/2943882 to your computer and use it in GitHub Desktop.
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 | |
attr_accessible :image, :name, :provider, :screen_name, :uid | |
def self.find_or_create_with_omniauth(auth) | |
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) | |
unless user | |
user = User.new | |
user[:provider] = auth["provider"] | |
user[:uid] = auth["uid"] | |
unless auth["info"].blank? | |
user[:name] = auth["info"]["name"] | |
user[:screen_name] = auth["info"]["nickname"] | |
user[:image] = auth["info"]["image"] | |
end | |
user.save | |
end | |
user | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment