Sha256: 4b0476044be33b113c882eaf1a3d4797b84c2e6e57e5bdfaa57d14bc6799afa7

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

require 'active_support/concern'

module ActsAsRecursiveTree
  module Associations
    extend ActiveSupport::Concern

    included do
      belongs_to :parent,
                 class_name:  self.base_class.to_s,
                 foreign_key: self._recursive_tree_config.parent_key,
                 inverse_of:  :children,
                 optional:    true

      has_many :children,
               class_name:  self.base_class.to_s,
               foreign_key: self._recursive_tree_config.parent_key,
               inverse_of:  :parent

      has_many :self_and_siblings,
               class_name:  self.base_class.to_s,
               primary_key: self._recursive_tree_config.parent_key,
               foreign_key: self._recursive_tree_config.parent_key
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts_as_recursive_tree-2.0.2 lib/acts_as_recursive_tree/associations.rb
acts_as_recursive_tree-2.0.1 lib/acts_as_recursive_tree/associations.rb
acts_as_recursive_tree-2.0.0 lib/acts_as_recursive_tree/associations.rb