Class: Binda::Repeater
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Binda::Repeater
- Includes:
- FieldableAssociations, Fields
- Defined in:
- app/models/binda/repeater.rb
Instance Method Summary collapse
-
#set_default_position ⇒ object
Set default position after create.
Methods included from FieldableAssociations
#find_or_create_a_field_by, #generate_fields
Instance Method Details
#set_default_position ⇒ object
Set default position after create
This methods ensure that every repeater instance has an explicit position.
The latest repeater created gets the highest position number.
19 20 21 22 23 24 25 26 27 |
# File 'app/models/binda/repeater.rb', line 19 def set_default_position Repeater .where( field_setting_id: self.field_setting_id, fieldable_id: self.fieldable_id, fieldable_type: self.fieldable_type ) .each{|repeater| repeater.increment(:position).save!} end |