Im using the awesome nested set plugin for ruby on rails. How do I go about sorting by like :name column or something ?
Currently shows the tree like
A
- C
- B
I want it like
A
- B
- C
Doing this overrides the database sort:
@item.children.except(:order).order("your_sort_column")
Example:
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With