1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/models/person.rb

35 lines
792 B
Ruby

# frozen_string_literal: true
class Person < ApplicationRecord
include Nameable
################
# Associations #
################
belongs_to :regional_office, optional: true
belongs_to :contacts_list
has_one :account, dependent: :restrict_with_exception
has_many :relationships,
-> { order(number: :asc) },
inverse_of: :person,
dependent: :restrict_with_exception
has_one :current_relationship,
-> { order(number: :desc) },
class_name: 'Relationship',
inverse_of: :person
has_many :person_comments, dependent: :restrict_with_exception
has_many :passports, dependent: :restrict_with_exception
###############
# Validations #
###############
validates :contacts_list, uniqueness: true
end