Class: Adminpanel::Gallery
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Adminpanel::Gallery
- Defined in:
- app/models/adminpanel/gallery.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 |
# File 'app/models/adminpanel/gallery.rb', line 16 def move_to_better_position if position > 1 conflicting_gallery = Gallery.find_by_position(position - 1) update_attribute(:position, position - 1) conflicting_gallery.update_attribute( :position, conflicting_gallery.position + 1 ) true else false end end |
#move_to_worst_position ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/adminpanel/gallery.rb', line 29 def move_to_worst_position records = Gallery.count if position < records conflicting_gallery = Gallery.find_by_position(position + 1) update_attribute(:position, position + 1) conflicting_gallery.update_attribute( :position, conflicting_gallery.position - 1 ) true else false end end |