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