Categories: None [Edit]
make_like_a_tree
Implement orderable trees in ActiveRecord using the nested set model, with multiple roots and scoping, and most importantly user-defined
ordering of subtrees. Fetches preordered trees in one go, updates are write-heavy.
This is a substantially butchered-up version/offspring of acts_as_threaded. The main additional perk is the ability
to reorder nodes, which are always fetched ordered. Example:
root = Folder.create! :name => "Main folder"
subfolder_1 = Folder.create! :name => "Subfolder", :parent_id => root.id
subfolder_2 = Folder.create! :name => "Another subfolder", :parent_id => root.id
subfolder_2.move_to_top # just like acts_as_list but nestedly awesome
root.all_children # => [subfolder_2, subfolder_1]
See the rdocs for examples the method names. It also inherits the awesome properties of acts_as_threaded, namely
materialized depth, root_id and parent_id values on each object which are updated when nodes get moved.
Thanks to the authors of acts_as_threaded, awesome_nested_set, better_nested_set and all the others for inspiration.
Total
Ranking: 128,504 of 183,139
Downloads: 4,410
Daily
Ranking: 66,923 of 183,127
Downloads: 0
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|
Depends on
Rank | Downloads | Name |
---|---|---|
2,089 | 8,575,570 | hoe |
Owners
# | Gravatar | Handle |
---|---|---|
1 | julik |