collectiveidea/awesome_nested_set

Is there an easy way to change the order of elements (left or right) in the same parent?

Closed this issue · 2 comments

Is there an easy way to change the order of elements (left or right) in the same parent?

I'm missing something like category.move_left (for only one step) or category.move_left_most.

Also it would be good to be able to move to a specific position by providing the target element's ID.

@jmuheim I also needed this. Couldn't find it in the docs or cheat sheet. But this gem does provide this functionality. To change the order of children of the same parent you could use the move_to_right_of and move_to_left_of methods.

So for example. Let's say B and C are both children of A. If you want to move C to appear before B then you can do C.move_to_left_of(B.id) or B.move_to_right_of(C.id).

As you can see, if you know the details of the target and source elements, you can move them around as your heart desires.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.