提交 133742d1 编写于 作者: A Aaron Patterson

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

上级 b1f5e908
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册