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) - 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
MenuNode.where(parent: menu).ordered
node.move_to_topThis is what powers drag & drop reordering (SortableJS) in the admin lists.