Files
nairobi/app/models/identity.rb
2019-04-17 17:40:56 +02:00

11 lines
281 B
Ruby

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