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
module ActsAsList
# positions can get mixed up when users click like crazy -> reorder them if necessary
# ActsAsList.reorder_positions!(current_user.categories)
def self.reorder_positions!(objects)
objects.each_with_index do |object, index|
new_position = index + 1
next if object.position == new_position
object.update_attribute(:position, new_position)
end
end
end
I have this tree:
parent_id: 1
parent_id: 2
when I change parent_id attribute at item A: parent_id = 2 and save, it does not recalculate item positions of all lists! I get this lists after save:
parent_id: 1
parent_id: 2
and correct lists are:
parent_id: 1
parent_id: 2
Which method should I call to do this right order? Thank you.
The text was updated successfully, but these errors were encountered: