在默认 AwesomeNestedSet 中,gem按以下方式排序:lft属性。假设我有一个班级:
class Category < ActiveRecord::Base
acts_as_nested_set
attr_accessible :name, :position, :parent_id, :lft, :rgt
end
如何创建一个带有 AwesomeNestedSet gem的可排序(by:position属性)树,其中一个命中数据库,其中:position用于排序兄弟(level)?
我需要这样的输出:
---------------------------------- id |position | name | parent_id | ---------------------------------- 1 | 1 | item1 | nil | ---------------------------------- 2 | 1 | item11 | 1 | ---------------------------------- 3 | 1 | item111| 2 | ---------------------------------- 4 | 2 | item12 | 1 | ---------------------------------- 5 | 2 | item2 | nil | ----------------------------------