2012-02-25 16:30:42 +00:00
|
|
|
class User < ActiveRecord::Base
|
|
|
|
|
|
|
|
validate :provider, :presence => true
|
|
|
|
validate :uid, :presence => true
|
2012-02-26 19:11:09 +00:00
|
|
|
validate :nickname, :presence => true
|
2012-02-25 16:30:42 +00:00
|
|
|
|
|
|
|
def self.create_with_omniauth(auth)
|
|
|
|
create! do |user|
|
2012-02-26 16:55:19 +00:00
|
|
|
user.provider = auth["provider"]
|
|
|
|
user.uid = auth["uid"]
|
2012-02-26 19:11:09 +00:00
|
|
|
user.nickname = auth["info"]["nickname"]
|
2012-02-26 16:55:19 +00:00
|
|
|
user.name = auth["info"]["name"]
|
|
|
|
user.avatar_url = OauthHelper.get_avatar_url(auth)
|
2012-02-25 16:30:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|