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/relationship.rb

25 lines
556 B
Ruby

# frozen_string_literal: true
class Relationship < ApplicationRecord
pg_enum :status, %i[supporter excluded member]
pg_enum :role, %i[manager supervisor]
################
# Associations #
################
belongs_to :person, inverse_of: :all_relationships
belongs_to :regional_office, inverse_of: :all_relationships
###############
# Validations #
###############
validates :from_date, presence: true, uniqueness: { scope: :person_id }
validates :status, presence: true
validates :role, absence: { unless: :member? }
end