gpt4 book ai didi

ruby-on-rails - 如何使用 awesome_nested_set 对节点内的节点重新排序

转载 作者:行者123 更新时间:2023-12-04 03:53:57 25 4
gpt4 key购买 nike

如果我有一棵这样的树:

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

使用 awesome_nested_set,我如何在 Page1 节点内向上或向下移动 Page1.x?

谢谢。

最佳答案

来自 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

关于ruby-on-rails - 如何使用 awesome_nested_set 对节点内的节点重新排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2640553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com