You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found an odd behaviour when destroing a list item. when it's invoked decrement_positions_on_lower_items method al the lower items' position are set to deleted item's position. for example:
@piccio: Sorry for the really really late response, but I think test_delete_middle tests this behavior and this might have been fixed during last couple of merges / commits.
I found an odd behaviour when destroing a list item. when it's invoked decrement_positions_on_lower_items method al the lower items' position are set to deleted item's position. for example:
[ < Item id:1, position: 1 >, < Item id:2, position: 2 >, < Item id:3, position: 3 >, < Item id:4, position: 4 > ]
if I delete the item with id = 2 the resulting list is:
[ < Item id:1, position: 1 >, < Item id:3, position: 2 >, < Item id:4, position: 2 > ]
instead of:
[ < Item id:1, position: 1 >, < Item id:3, position: 2 >, < Item id:4, position: 3 > ]
I resolved overriding decrement_positions_on_lower_items method:
def decrement_positions_on_lower_items
return unless in_list?
acts_as_list_class.each do |l|
l.update(
"#{position_column} = (#{position_column} - 1)",
"#{scope_condition} AND #{position_column} > #{send(position_column).to_i}"
)
end
end
The text was updated successfully, but these errors were encountered: