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

38 lines
865 B
Ruby
Raw Normal View History

2018-12-10 08:32:35 +05:00
# frozen_string_literal: true
class Person < ApplicationRecord
2019-03-27 01:40:53 +05:00
include Nameable
2019-03-26 05:56:31 +05:00
################
# Associations #
################
2018-12-15 10:54:45 +05:00
belongs_to :regional_office, optional: true
2018-12-15 09:09:43 +05:00
2019-06-27 05:21:37 +05:00
belongs_to :contacts_list
2018-12-10 08:36:09 +05:00
has_one :account, dependent: :restrict_with_exception
2018-12-15 09:20:13 +05:00
2019-04-28 19:12:02 +05:00
has_many :relationships,
-> { order(number: :asc) },
inverse_of: :person,
dependent: :restrict_with_exception
2019-04-28 18:08:02 +05:00
has_one :current_relationship,
-> { order(number: :desc) },
class_name: 'Relationship',
inverse_of: :person
2019-07-16 02:19:11 +05:00
has_many :person_comments, dependent: :restrict_with_exception
has_many :passports, dependent: :restrict_with_exception
2019-03-26 04:11:52 +05:00
has_many :resident_registrations, dependent: :restrict_with_exception
2019-06-27 05:21:37 +05:00
###############
# Validations #
###############
validates :contacts_list, uniqueness: true
2018-12-10 08:32:35 +05:00
end