Sha256: d3954b2664f64056eb13c07e24c22e0b341e569d26dc37ca55ad93630ed2fecd
Contents?: true
Size: 830 Bytes
Versions: 1
Compression:
Stored size: 830 Bytes
Contents
# frozen_string_literals: true module Jobshop class Person < ApplicationRecord self.primary_keys = %i[ organization_id person_id ] after_initialize { self.person_id ||= SecureRandom.uuid if new_record? } belongs_to :organization, inverse_of: :people has_one :company_person, inverse_of: :person, foreign_key: %i[ organization_id person_id ] has_one :company, through: :company_person, foreign_key: %i[ organization_id company_id ] validates :email, presence: { if: :email_required? }, format: { if: :email_required?, with: /\A[^@\s]+@[^@\s]+\z/ }, uniqueness: { if: :email_changed?, scope: :organization_id, case_sensitive: false } def name @name = [ forename, surname ].join(" ") end private def email_required? true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jobshop-0.0.163 | app/models/jobshop/person.rb |