mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
support finding by a ruby class [#5979 state:resolved]
This commit is contained in:
@@ -27,6 +27,9 @@ module ActiveRecord
|
||||
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 @@ class RelationTest < ActiveRecord::TestCase
|
||||
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])
|
||||
|
||||
Reference in New Issue
Block a user