diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/plugins/acts_as_list/lib/active_record/acts/list.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/plugins/acts_as_list/lib/active_record/acts/list.rb b/lib/plugins/acts_as_list/lib/active_record/acts/list.rb index 9361a768c..3c1ba5216 100644 --- a/lib/plugins/acts_as_list/lib/active_record/acts/list.rb +++ b/lib/plugins/acts_as_list/lib/active_record/acts/list.rb @@ -233,39 +233,39 @@ module ActiveRecord # This has the effect of moving all the higher items up one. def decrement_positions_on_higher_items(position) - acts_as_list_class.update_all( - "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} <= #{position}" - ) + acts_as_list_class. + where("#{scope_condition} AND #{position_column} <= #{position}"). + update_all("#{position_column} = (#{position_column} - 1)") end # This has the effect of moving all the lower items up one. def decrement_positions_on_lower_items return unless in_list? - acts_as_list_class.update_all( - "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} > #{send(position_column).to_i}" - ) + acts_as_list_class. + where("#{scope_condition} AND #{position_column} > #{send(position_column).to_i}"). + update_all("#{position_column} = (#{position_column} - 1)") end # This has the effect of moving all the higher items down one. def increment_positions_on_higher_items return unless in_list? - acts_as_list_class.update_all( - "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} < #{send(position_column).to_i}" - ) + acts_as_list_class. + where("#{scope_condition} AND #{position_column} < #{send(position_column).to_i}"). + update_all("#{position_column} = (#{position_column} + 1)") end # This has the effect of moving all the lower items down one. def increment_positions_on_lower_items(position) - acts_as_list_class.update_all( - "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} >= #{position}" - ) + acts_as_list_class. + where("#{scope_condition} AND #{position_column} >= #{position}"). + update_all("#{position_column} = (#{position_column} + 1)") end # Increments position (<tt>position_column</tt>) of all items in the list. def increment_positions_on_all_items - acts_as_list_class.update_all( - "#{position_column} = (#{position_column} + 1)", "#{scope_condition}" - ) + acts_as_list_class. + where("#{scope_condition}"). + update_all("#{position_column} = (#{position_column} + 1)") end def insert_at_position(position) |