令人敬畏的嵌套集顺序

And*_*nic 3 treeview ruby-on-rails awesome-nested-set

我在轨道上使用了令人敬畏的嵌套设置插件.我如何进行排序:name column or something?

目前显示树状

A
- C
- B
Run Code Online (Sandbox Code Playgroud)

我想要它

A
- B
- C
Run Code Online (Sandbox Code Playgroud)

小智 5

这样做会覆盖数据库排序:

@item.children.except(:order).order("your_sort_column")
Run Code Online (Sandbox Code Playgroud)

例:

organization.self_and_descendants.to_sql
=> "SELECT `organizations`.* FROM `organizations`  WHERE (`organizations`.`lft` >= 1 AND `organizations`.`lft` < 54) ORDER BY `organizations`.`lft`" 

organization.self_and_descendants.except(:order).order("organization_nm").to_sql
=> "SELECT `organizations`.* FROM `organizations`  WHERE (`organizations`.`lft` >= 1 AND `organizations`.`lft` < 54) ORDER BY organization_nm" 
Run Code Online (Sandbox Code Playgroud)