use lambda form in acts_as_tree scope (#12499)

git-svn-id: http://svn.redmine.org/redmine/trunk@12487 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2014-01-07 10:02:50 +00:00
parent e17bf40fe1
commit a5f028a242
1 changed files with 4 additions and 2 deletions

View File

@ -46,8 +46,10 @@ module ActiveRecord
belongs_to :parent, :class_name => name, :foreign_key => configuration[:foreign_key], :counter_cache => configuration[:counter_cache] 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] 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 send :include, ActiveRecord::Acts::Tree::InstanceMethods
end end
end end