Files
nairobi/app/models/identity.rb
2015-08-24 20:24:10 +02:00

11 lines
270 B
Ruby

class Identity < ActiveRecord::Base
belongs_to :user
validates :provider, presence: true
validates :uid, presence: true, uniqueness: { scope: :provider }
def self.find_for_oauth(auth)
where(uid: auth.uid, provider: auth.provider).first_or_create
end
end