From 76110407b70e33d8bf1efdd7f731645a9009048d Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Wed, 8 Jan 2014 04:13:18 +0000 Subject: Rails4: replace deprecated Relation#update_all at acts_as_list git-svn-id: http://svn.redmine.org/redmine/trunk@12504 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../acts_as_list/lib/active_record/acts/list.rb | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'lib/plugins/acts_as_list') 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 (position_column) 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) -- cgit v1.2.3