Module: Kms::Positioned
- Extended by:
- ActiveSupport::Concern
- Included in:
- Page
- Defined in:
- app/models/concerns/kms/positioned.rb
Instance Method Summary collapse
Instance Method Details
#set_position ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/models/concerns/kms/positioned.rb', line 9 def set_position if parent.present? max = parent.children.maximum(:position) else max = self.class.where('ancestry IS ?', nil).maximum(:position) end self.position = max ? max + 1 : 0 end |