diff options
author | Marcel Molina <marcel@vernix.org> | 2005-10-09 18:51:30 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2005-10-09 18:51:30 +0000 |
commit | c8e364a93f6c2de80fb56ddf2f6a46b6e96f4a9d (patch) | |
tree | c951660f1eee0891fccd6f765ae78e6919859cff /activerecord/lib | |
parent | 5ef931a4b879ed2f380b393000edbdb4c50f8150 (diff) | |
download | rails-c8e364a93f6c2de80fb56ddf2f6a46b6e96f4a9d.tar.gz rails-c8e364a93f6c2de80fb56ddf2f6a46b6e96f4a9d.tar.bz2 rails-c8e364a93f6c2de80fb56ddf2f6a46b6e96f4a9d.zip |
Add ability to get all siblings, including the current child, with acts_as_tree. Recloses #2140.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2507 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/acts/tree.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/acts/tree.rb b/activerecord/lib/active_record/acts/tree.rb index 5fc7ddf41c..9cf5c3f732 100644 --- a/activerecord/lib/active_record/acts/tree.rb +++ b/activerecord/lib/active_record/acts/tree.rb @@ -71,8 +71,13 @@ module ActiveRecord end define_method(:siblings) do - ( has_parent? ? parent.children : self.class.roots ) - [self] + self_and_siblings - [self] end + + define_method(:self_and_siblings) do + has_parent? ? parent.children : self.class.roots + end + end end end |