Created
February 28, 2013 14:58
-
-
Save shuma/5057344 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 | |
def self.from_omniauth(auth) | |
where(auth.slice(:provider, :uid)).first_or_create do |user| | |
user.provider = auth.provider | |
user.uid = auth.uid | |
user.name = auth.info.name | |
user.email = auth.info.email | |
user.image = auth.info.image | |
user.location = auth.info.location | |
user.gender = auth.extra.raw_info.gender | |
user.urls = auth["info"]["urls"]["Facebook"] | |
user.oauth_token = auth.credentials.token | |
user.oauth_expires_at = Time.at(auth.credentials.expires_at) | |
user.save! | |
user.add_friends | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment