From 13547c16d97b5f52db11d9f48704bbea20b54a4c Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Tue, 15 Feb 2011 21:48:11 -0500 Subject: fixes: ActiveRecord::Base.scopes includes all scopes defined in all subclasses --- activerecord/lib/active_record/named_scope.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/named_scope.rb') diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index 0f421560f0..d291632260 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -102,10 +102,9 @@ module ActiveRecord def scope(name, scope_options = {}) name = name.to_sym valid_scope_name?(name) - extension = Module.new(&Proc.new) if block_given? - scopes[name] = lambda do |*args| + scope_proc = lambda do |*args| options = scope_options.respond_to?(:call) ? scope_options.call(*args) : scope_options relation = if options.is_a?(Hash) @@ -119,6 +118,8 @@ module ActiveRecord extension ? relation.extending(extension) : relation end + self.scopes = self.scopes.merge name => scope_proc + singleton_class.send(:redefine_method, name, &scopes[name]) end -- cgit v1.2.3