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
This commit is contained in:
parent
6dcfa742fd
commit
76110407b7
|
@ -233,39 +233,39 @@ module ActiveRecord
|
||||||
|
|
||||||
# This has the effect of moving all the higher items up one.
|
# This has the effect of moving all the higher items up one.
|
||||||
def decrement_positions_on_higher_items(position)
|
def decrement_positions_on_higher_items(position)
|
||||||
acts_as_list_class.update_all(
|
acts_as_list_class.
|
||||||
"#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} <= #{position}"
|
where("#{scope_condition} AND #{position_column} <= #{position}").
|
||||||
)
|
update_all("#{position_column} = (#{position_column} - 1)")
|
||||||
end
|
end
|
||||||
|
|
||||||
# This has the effect of moving all the lower items up one.
|
# This has the effect of moving all the lower items up one.
|
||||||
def decrement_positions_on_lower_items
|
def decrement_positions_on_lower_items
|
||||||
return unless in_list?
|
return unless in_list?
|
||||||
acts_as_list_class.update_all(
|
acts_as_list_class.
|
||||||
"#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} > #{send(position_column).to_i}"
|
where("#{scope_condition} AND #{position_column} > #{send(position_column).to_i}").
|
||||||
)
|
update_all("#{position_column} = (#{position_column} - 1)")
|
||||||
end
|
end
|
||||||
|
|
||||||
# This has the effect of moving all the higher items down one.
|
# This has the effect of moving all the higher items down one.
|
||||||
def increment_positions_on_higher_items
|
def increment_positions_on_higher_items
|
||||||
return unless in_list?
|
return unless in_list?
|
||||||
acts_as_list_class.update_all(
|
acts_as_list_class.
|
||||||
"#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} < #{send(position_column).to_i}"
|
where("#{scope_condition} AND #{position_column} < #{send(position_column).to_i}").
|
||||||
)
|
update_all("#{position_column} = (#{position_column} + 1)")
|
||||||
end
|
end
|
||||||
|
|
||||||
# This has the effect of moving all the lower items down one.
|
# This has the effect of moving all the lower items down one.
|
||||||
def increment_positions_on_lower_items(position)
|
def increment_positions_on_lower_items(position)
|
||||||
acts_as_list_class.update_all(
|
acts_as_list_class.
|
||||||
"#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} >= #{position}"
|
where("#{scope_condition} AND #{position_column} >= #{position}").
|
||||||
)
|
update_all("#{position_column} = (#{position_column} + 1)")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Increments position (<tt>position_column</tt>) of all items in the list.
|
# Increments position (<tt>position_column</tt>) of all items in the list.
|
||||||
def increment_positions_on_all_items
|
def increment_positions_on_all_items
|
||||||
acts_as_list_class.update_all(
|
acts_as_list_class.
|
||||||
"#{position_column} = (#{position_column} + 1)", "#{scope_condition}"
|
where("#{scope_condition}").
|
||||||
)
|
update_all("#{position_column} = (#{position_column} + 1)")
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_at_position(position)
|
def insert_at_position(position)
|
||||||
|
|
Loading…
Reference in New Issue