summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-02 20:41:03 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-02 20:41:03 +0000
commit282a13d6eea3aa8c6530bdf14cdd86229b095e30 (patch)
tree97411748e9cfba685109c37d01270b6e419b1144 /lib
parentabd921736b6db3a405c6505b3bf4022bb9097d41 (diff)
downloadredmine-282a13d6eea3aa8c6530bdf14cdd86229b095e30.tar.gz
redmine-282a13d6eea3aa8c6530bdf14cdd86229b095e30.zip
Replaces acts_as_tree #roots class method with a scope.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10919 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/plugins/acts_as_tree/lib/active_record/acts/tree.rb12
1 files changed, 1 insertions, 11 deletions
diff --git a/lib/plugins/acts_as_tree/lib/active_record/acts/tree.rb b/lib/plugins/acts_as_tree/lib/active_record/acts/tree.rb
index a1c83cf50..4e5f37182 100644
--- a/lib/plugins/acts_as_tree/lib/active_record/acts/tree.rb
+++ b/lib/plugins/acts_as_tree/lib/active_record/acts/tree.rb
@@ -46,17 +46,7 @@ module ActiveRecord
belongs_to :parent, :class_name => name, :foreign_key => configuration[:foreign_key], :counter_cache => configuration[:counter_cache]
has_many :children, :class_name => name, :foreign_key => configuration[:foreign_key], :order => configuration[:order], :dependent => configuration[:dependent]
- class_eval <<-EOV
- include ActiveRecord::Acts::Tree::InstanceMethods
-
- def self.roots
- find(:all, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
- end
-
- def self.root
- find(:first, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
- end
- EOV
+ scope :roots, where("#{configuration[:foreign_key]} IS NULL").order(configuration[:order])
end
end