2017-06-23 15:19:08 +02:00
|
|
|
class ProtocolKeyword < ApplicationRecord
|
2016-09-21 15:35:23 +02:00
|
|
|
auto_strip_attributes :name, nullify: false
|
2016-09-29 14:12:52 +02:00
|
|
|
validates :name,
|
2018-06-18 12:15:52 +02:00
|
|
|
uniqueness: { scope: :team },
|
2016-10-05 17:45:20 +02:00
|
|
|
length: { minimum: Constants::NAME_MIN_LENGTH,
|
|
|
|
maximum: Constants::NAME_MAX_LENGTH }
|
2017-01-24 16:34:21 +01:00
|
|
|
validates :team, presence: true
|
2016-07-21 13:11:15 +02:00
|
|
|
|
2019-05-09 17:10:02 +02:00
|
|
|
belongs_to :team, inverse_of: :protocol_keywords
|
2016-07-21 13:11:15 +02:00
|
|
|
|
2017-01-24 16:34:21 +01:00
|
|
|
has_many :protocol_protocol_keywords,
|
|
|
|
inverse_of: :protocol_keyword,
|
|
|
|
dependent: :destroy
|
2016-07-21 13:11:15 +02:00
|
|
|
has_many :protocols, through: :protocol_protocol_keywords
|
2016-10-05 17:45:20 +02:00
|
|
|
end
|