From a5f028a2424e2e234081b6a84c496fb6c563ee9c Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Tue, 7 Jan 2014 10:02:50 +0000 Subject: [PATCH] use lambda form in acts_as_tree scope (#12499) 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 d069da972..34fa34560 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,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