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

33 lines
637 B
Ruby
Raw Normal View History

2019-04-27 10:24:04 -04:00
# frozen_string_literal: true
class Relationship < ApplicationRecord
2019-07-21 22:30:58 -04:00
enum status: {
supporter: 'supporter',
excluded: 'excluded',
member: 'member',
}
enum role: {
manager: 'manager',
supervisor: 'supervisor',
}
2019-06-04 22:33:45 -04:00
2019-04-27 10:24:04 -04:00
################
# Associations #
################
belongs_to :person, inverse_of: :all_relationships
2019-07-20 06:52:03 -04:00
belongs_to :regional_office, inverse_of: :all_relationships
2019-04-28 08:48:51 -04:00
###############
# Validations #
###############
validates :from_date, presence: true, uniqueness: { scope: :person_id }
2019-06-04 22:33:45 -04:00
validates :status, presence: true
2019-07-20 05:12:58 -04:00
validates :role, absence: { unless: :member? }
2019-04-27 10:24:04 -04:00
end