]> source.dussan.org Git - redmine.git/commitdiff
use lambda form in acts_as_tree scope (#12499)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 7 Jan 2014 10:02:50 +0000 (10:02 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 7 Jan 2014 10:02:50 +0000 (10:02 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12487 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/plugins/acts_as_tree/lib/active_record/acts/tree.rb

index d069da9723dad6c0bd65007fc6e45edadb0eb1b8..34fa3456069747a09bc3367430228871544cc7a6 100644 (file)
@@ -46,8 +46,10 @@ 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]
 
-          scope :roots, where("#{configuration[:foreign_key]} IS NULL").order(configuration[:order])
-
+          scope :roots, lambda {
+                          where("#{configuration[:foreign_key]} IS NULL").
+                            order(configuration[:order])
+                        }
           send :include, ActiveRecord::Acts::Tree::InstanceMethods
         end
       end