scinote-web/app/models/protocol_keyword.rb

11 lines
440 B
Ruby
Raw Normal View History

2016-07-21 19:11:15 +08:00
class ProtocolKeyword < ActiveRecord::Base
auto_strip_attributes :name, nullify: false
2016-09-29 20:12:52 +08:00
validates :name,
length: { minimum: NAME_MIN_LENGTH, maximum: NAME_MAX_LENGTH }
2016-07-21 19:11:15 +08:00
validates :organization, presence: true
belongs_to :organization, inverse_of: :protocol_keywords
has_many :protocol_protocol_keywords, inverse_of: :protocol_keyword, dependent: :destroy
has_many :protocols, through: :protocol_protocol_keywords
end