From cfa283201e079b4f700eb915490bcfa18451b11e Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Fri, 2 Apr 2010 18:57:01 +0100 Subject: Goodbye ActiveRecord::NamedScope::Scope --- activerecord/lib/active_record/relation.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/lib/active_record/relation.rb') diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 3ca27f06ea..69d04d7375 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -311,11 +311,22 @@ module ActiveRecord @should_eager_load ||= (@eager_load_values.any? || (@includes_values.any? && references_eager_loaded_tables?)) end + def ==(other) + case other + when Relation + other.to_sql == to_sql + when Array + to_a == other.to_a + end + end + protected def method_missing(method, *args, &block) if Array.method_defined?(method) to_a.send(method, *args, &block) + elsif @klass.scopes[method] + merge(@klass.send(method, *args, &block)) elsif @klass.respond_to?(method) @klass.send(:with_scope, self) { @klass.send(method, *args, &block) } elsif arel.respond_to?(method) -- cgit v1.2.3