aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/acts/tree.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/acts/tree.rb')
-rw-r--r--activerecord/lib/active_record/acts/tree.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/acts/tree.rb b/activerecord/lib/active_record/acts/tree.rb
index b92587e521..5e2e50552d 100644
--- a/activerecord/lib/active_record/acts/tree.rb
+++ b/activerecord/lib/active_record/acts/tree.rb
@@ -5,8 +5,8 @@ module ActiveRecord
base.extend(ClassMethods)
end
- # Specify this act if you want to model a tree structure by providing a parent association and a children
- # association. This act requires that you have a foreign key column, which by default is called parent_id.
+ # Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
+ # association. This requires that you have a foreign key column, which by default is called +parent_id+.
#
# class Category < ActiveRecord::Base
# acts_as_tree :order => "name"
@@ -28,17 +28,17 @@ module ActiveRecord
# root.children.first.children.first # => subchild1
#
# In addition to the parent and children associations, the following instance methods are added to the class
- # after specifying the act:
- # * siblings : Returns all the children of the parent, excluding the current node ([ subchild2 ] when called from subchild1)
- # * self_and_siblings : Returns all the children of the parent, including the current node ([ subchild1, subchild2 ] when called from subchild1)
- # * ancestors : Returns all the ancestors of the current node ([child1, root] when called from subchild2)
- # * root : Returns the root of the current node (root when called from subchild2)
+ # after calling <tt>acts_as_tree</tt>:
+ # * <tt>siblings</tt> - Returns all the children of the parent, excluding the current node (<tt>[subchild2]</tt> when called on <tt>subchild1</tt>)
+ # * <tt>self_and_siblings</tt> - Returns all the children of the parent, including the current node (<tt>[subchild1, subchild2]</tt> when called on <tt>subchild1</tt>)
+ # * <tt>ancestors</tt> - Returns all the ancestors of the current node (<tt>[child1, root]</tt> when called on <tt>subchild2</tt>)
+ # * <tt>root</tt> - Returns the root of the current node (<tt>root</tt> when called on <tt>subchild2</tt>)
module ClassMethods
# Configuration options are:
#
- # * <tt>foreign_key</tt> - specifies the column name to use for tracking of the tree (default: parent_id)
+ # * <tt>foreign_key</tt> - specifies the column name to use for tracking of the tree (default: +parent_id+)
# * <tt>order</tt> - makes it possible to sort the children according to this SQL snippet.
- # * <tt>counter_cache</tt> - keeps a count in a children_count column if set to true (default: false).
+ # * <tt>counter_cache</tt> - keeps a count in a +children_count+ column if set to +true+ (default: +false+).
def acts_as_tree(options = {})
configuration = { :foreign_key => "parent_id", :order => nil, :counter_cache => nil }
configuration.update(options) if options.is_a?(Hash)