From 9c7c7104f6a6074681f554c016f1b15a9ef8d267 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Tue, 19 Jan 2010 17:45:48 +0530 Subject: Fix the named scope equality check --- activerecord/lib/active_record/named_scope.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 92030e5bfd..f1b8822892 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -182,7 +182,7 @@ module ActiveRecord end def ==(other) - to_a == other.to_a + other.respond_to?(:to_a) ? to_a == other.to_a : false end private -- cgit v1.2.3 From d8c30723aad943da20fed36cceedba6225122a3a Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 20 Jan 2010 01:35:20 +0530 Subject: Named scopes dont need count() now that Relation#count handles all the cases --- activerecord/lib/active_record/named_scope.rb | 5 ----- 1 file changed, 5 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 f1b8822892..2f3044d06b 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -176,11 +176,6 @@ module ActiveRecord end end - def count(*args) - options = args.extract_options! - options.present? ? apply_finder_options(options).count(*args) : super - end - def ==(other) other.respond_to?(:to_a) ? to_a == other.to_a : false end -- cgit v1.2.3 From 565b4cd3e08c148a6c8f2e80c28029c6a8a51e6e Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 20 Jan 2010 03:40:37 +0530 Subject: Scope#find is no longer needed now that Relation#find handles all the cases --- activerecord/lib/active_record/named_scope.rb | 12 ------------ 1 file changed, 12 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 2f3044d06b..d606934dce 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -148,18 +148,6 @@ module ActiveRecord relation end - def find(*args) - options = args.extract_options! - relation = options.present? ? apply_finder_options(options) : self - - case args.first - when :first, :last, :all - relation.send(args.first) - else - options.present? ? relation.find(*args) : super - end - end - def first(*args) if args.first.kind_of?(Integer) || (loaded? && !args.first.kind_of?(Hash)) to_a.first(*args) -- cgit v1.2.3 From f7d94cdc6d01617ff4579fda6a56a3e94be47ffe Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 20 Jan 2010 20:40:20 +0530 Subject: Fix AP's AR integration tests warning --- activerecord/lib/active_record/named_scope.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 d606934dce..ff6c041ef4 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -165,7 +165,7 @@ module ActiveRecord end def ==(other) - other.respond_to?(:to_a) ? to_a == other.to_a : false + other.respond_to?(:to_ary) ? to_a == other.to_a : false end private -- cgit v1.2.3