From 8d99ec9a4dcef5918c4487a0d94ef0a9622fe8c9 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 30 Mar 2010 10:41:56 -0300 Subject: Named scopes shouldn't test equality using to_a if it's not an Array, this was causing records to be loaded before they were needed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activerecord/lib/active_record/named_scope.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index aac00cc54a..9abf979cd0 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -167,7 +167,14 @@ module ActiveRecord end def ==(other) - other.respond_to?(:to_ary) ? to_a == other.to_a : false + case other + when Scope + to_sql == other.to_sql + when Relation + other == self + when Array + to_a == other.to_a + end end private -- cgit v1.2.3