提交 ace84a00 编写于 作者: A Aaron Patterson

support finding by a ruby class [#5979 state:resolved]

上级 7bf9cbb7
......@@ -27,6 +27,9 @@ def self.build_from_hash(engine, attributes, default_table)
attribute.in(value)
when ActiveRecord::Base
attribute.eq(value.quoted_id)
when Class
# FIXME: I think we need to deprecate this behavior
attribute.eq(value.name)
else
attribute.eq(value)
end
......
......@@ -438,6 +438,13 @@ def test_find_with_list_of_ar
assert_equal author, authors.first
end
class Mary < Author; end
def test_find_by_classname
Author.create!(:name => Mary.name)
assert_equal 1, Author.where(:name => Mary).size
end
def test_find_by_id_with_list_of_ar
author = Author.first
authors = Author.find_by_id([author])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册