AyuntamientoMadrid/participacion

View on GitHub
app/models/identity.rb

Summary

Maintainability
A
0 mins
Test Coverage
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