开发者

How to reorder nodes within a node using awesome_nested_set

开发者 https://www.devze.com 2022-12-27 02:33 出处:网络
If I have a tree开发者_开发知识库 like this: Page1 ---Page1.1 ---Page1.2 ---Page1.3 Using awesome_nested_set, how would I move Page1.x up or down within the Page1 node?

If I have a tree开发者_开发知识库 like this:

Page1
---Page1.1
---Page1.2
---Page1.3

Using awesome_nested_set, how would I move Page1.x up or down within the Page1 node?

Thanks.


From http://github.com/collectiveidea/awesome_nested_set/blob/master/lib/awesome_nested_set.rb :

# Shorthand method for finding the left sibling and moving to the left of it.
def move_left
  move_to_left_of left_sibling
end

#Shorthand method for finding the right sibling and moving to the right of it.
def move_right
  move_to_right_of right_sibling
end

# Move the node to the left of another node (you can pass id only)
def move_to_left_of(node)
  move_to node, :left
end

# Move the node to the left of another node (you can pass id only)
def move_to_right_of(node)
  move_to node, :right
end
0

精彩评论

暂无评论...
验证码 换一张
取 消