Module: ActsAsRecursiveTree::ActsMacro

Defined in:
lib/acts_as_recursive_tree/acts_macro.rb

Instance Method Summary collapse

Instance Method Details

#recursive_tree(parent_key: :parent_id, parent_type_column: nil, dependent: nil) ⇒ Object Also known as: acts_as_tree

Configuration options are:

  • foreign_key - specifies the column name to use for tracking

of the tree (default: parent_id)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/acts_as_recursive_tree/acts_macro.rb', line 10

def recursive_tree(parent_key: :parent_id, parent_type_column: nil, dependent: nil)
  class_attribute(:_recursive_tree_config, instance_writer: false)

  self._recursive_tree_config = Config.new(
    model_class: self,
    parent_key: parent_key.to_sym,
    parent_type_column: parent_type_column.try(:to_sym),
    dependent:
  )

  include ActsAsRecursiveTree::Model
  include ActsAsRecursiveTree::Associations
  include ActsAsRecursiveTree::Scopes
end