2

このようなツリーがある場合:

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

awesome_nested_set を使用して、Page1 ノード内で Page1.x を上下に移動するにはどうすればよいですか?

ありがとう。

4

1 に答える 1

9

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
于 2010-04-15T08:47:06.943 に答える