Trek::Orderable
Position tracking with acts_as_list, scoped by parent.
What it adds
acts_as_list scope: :parent, top_of_list: 0- An
orderedscope (position order), which adds nothing on a closure_tree model such asPageorMenuNode: closure_tree already orders its records byposition - All the
acts_as_listinstance methods:insert_at,move_to_top,move_to_bottom,move_higher,move_lower…
Requirements
- A
positioninteger column (and aparent_idcolumn for the scope)
Usage
ruby
class MenuNode < ApplicationRecord
include Trek::Orderable
end
menu.children # ordered by position, through closure_tree
node.move_to_topThis is what powers drag & drop reordering (SortableJS) in the admin lists.