Permalink
Browse files

@klass also uses DynamicFinderMatch, so no need for it on the relation

  • Loading branch information...
1 parent 1e687e9 commit 409bd22a2d53ce6320e395d64e580e44f8a1c7e6 @tenderlove tenderlove committed Sep 27, 2010
Showing with 5 additions and 9 deletions.
  1. +0 −9 activerecord/lib/active_record/relation.rb
  2. +5 −0 activerecord/test/cases/relations_test.rb
@@ -366,15 +366,6 @@ def method_missing(method, *args, &block)
scoping { @klass.send(method, *args, &block) }
elsif arel.respond_to?(method)
arel.send(method, *args, &block)
- elsif match = DynamicFinderMatch.match(method)
- attributes = match.attribute_names
- super unless @klass.send(:all_attributes_exists?, attributes)
-
- if match.finder?
- find_by_attributes(match, attributes, *args)
- elsif match.instantiator?
- find_or_instantiator_by_attributes(match, attributes, *args, &block)
- end
else
super
end
@@ -32,6 +32,11 @@ def test_apply_relation_as_where_id
assert_equal 5, Post.where(:id => post_authors).size
end
+ def test_dynamic_finder
+ x = Post.where('author_id = ?', 1)
+ assert x.klass.respond_to?(:find_by_id), '@klass should handle dynamic finders'
+ end
+
def test_multivalue_where
posts = Post.where('author_id = ? AND id = ?', 1, 1)
assert_equal 1, posts.to_a.size

0 comments on commit 409bd22

Please sign in to comment.