From bc933d0fa1b3a89deaf3e7c74d7717eb8fc7152a Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Tue, 29 Dec 2009 12:27:40 +0530 Subject: Make sure Relation responds to dynamic finder methods --- activerecord/lib/active_record/relation.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 52a8bea567..d7cd78593f 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -143,7 +143,15 @@ module ActiveRecord end def respond_to?(method) - @relation.respond_to?(method) || Array.method_defined?(method) || super + return true if @relation.respond_to?(method) || Array.method_defined?(method) + + if match = DynamicFinderMatch.match(method) + return true if @klass.send(:all_attributes_exists?, match.attribute_names) + elsif match = DynamicScopeMatch.match(method) + return true if @klass.send(:all_attributes_exists?, match.attribute_names) + else + super + end end def to_a -- cgit v1.2.3