-
Notifications
You must be signed in to change notification settings - Fork 9
Use models with `acts_as_tree`
Elyjohn edited this page May 18, 2017
·
4 revisions
Your model needs to include the following pieces of code and you will get a drag-and-droppable index view instead of the classic table view.
class MyTreeModel < ActiveRecord::Base
acts_as_tree
class_attribute :max_depth
scope :ordered, -> { order(position: :asc) }
def self.max_depth
# return an integer
end
end
You can use closure_tree to make your model behave like a tree