1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

@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

View file

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

View file

@ -32,6 +32,11 @@ class RelationTest < ActiveRecord::TestCase
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