Module: Adminpanel::Galleryzation
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/adminpanel/galleryzation.rb
Instance Method Summary collapse
Instance Method Details
#move_to_better_position ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/concerns/adminpanel/galleryzation.rb', line 16 def move_to_better_position if self.position > 1 conflicting_gallery = get_conflicting_gallery(position - 1) self.update_attribute(:position, self.position - 1) conflicting_gallery.update_attribute( :position, conflicting_gallery.position + 1 ) true else false end end |
#move_to_worst_position ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/concerns/adminpanel/galleryzation.rb', line 31 def move_to_worst_position records = self.class.count if self.position < records conflicting_gallery = get_conflicting_gallery(position + 1) update_attribute(:position, self.position + 1) conflicting_gallery.update_attribute( :position, conflicting_gallery.position - 1 ) true else false end end |