1
0
Fork 0
find-us-lunch/app/models/user.rb

17 lines
454 B
Ruby
Raw Normal View History

2014-10-02 16:29:18 -04:00
class User < ActiveRecord::Base
2014-10-15 13:17:36 -04:00
has_many :friendships
has_many :friends, through: :friendships
2014-11-14 22:07:41 -05:00
scope :all_except, ->(user) { where.not(id: user) }
2014-10-02 16:29:18 -04:00
def self.from_omniauth(auth)
where(provider: auth[:provider], uid: auth[: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.save
end
end
end