Class: ConcertoManykinds::Manykind
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ConcertoManykinds::Manykind
- Includes:
- ActiveModel::ForbiddenAttributesProtection
- Defined in:
- app/models/concerto_manykinds/manykind.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.form_attributes ⇒ Object
26 27 28 |
# File 'app/models/concerto_manykinds/manykind.rb', line 26 def self.form_attributes attributes = [:field_id, :template_id, :kind_id] end |
.kinds_for(template_id, field_id) ⇒ Object
30 31 32 |
# File 'app/models/concerto_manykinds/manykind.rb', line 30 def self.kinds_for(template_id, field_id) Manykind.where(template_id: template_id, field_id: field_id) end |
Instance Method Details
#cannot_be_same_as_primary ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/models/concerto_manykinds/manykind.rb', line 17 def cannot_be_same_as_primary if template_id.present? && field_id.present? && kind_id.present? p = Position.where(template_id: template_id, field_id: field_id).first if !p.nil? && p.field.kind_id == kind_id errors.add(:kind_id, I18n.t('concerto_manykinds.already_mapped_via_template', kind: kind.name, field: field.name)) end end end |