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

This commit is contained in:
Aaron Patterson 2010-09-27 16:51:12 -07:00
parent b1f5e90839
commit 133742d185
2 changed files with 5 additions and 9 deletions

@ -358,15 +358,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