Module: Adminpanel::Galleryzation
- Extended by:
- ActiveSupport::Concern
- Included in:
- Gallery
- Defined in:
- app/models/concerns/adminpanel/galleryzation.rb
Instance Method Summary collapse
Instance Method Details
#move_to_better_position ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/concerns/adminpanel/galleryzation.rb', line 11 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
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/concerns/adminpanel/galleryzation.rb', line 26 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 |