mirror of https://github.com/rails/rails
parent
c9e9346730
commit
19850107cd
|
@ -324,7 +324,7 @@ module ActiveRecord
|
|||
hash = args.first
|
||||
return super unless Hash === hash
|
||||
|
||||
values = hash.values.map! { |value| value.is_a?(Base) ? value.id : value }
|
||||
values = hash.values.map! { |value| value.respond_to?(:id) ? value.id : value }
|
||||
return super if values.any? { |v| StatementCache.unsupported_value?(v) }
|
||||
|
||||
keys = hash.keys.map! do |key|
|
||||
|
|
|
@ -830,6 +830,13 @@ class RelationTest < ActiveRecord::TestCase
|
|||
assert_equal 3, Post.where(author: [decorator.new(author)]).to_a.length
|
||||
end
|
||||
|
||||
def test_find_by_with_delegated_ar_object
|
||||
decorator = Class.new(SimpleDelegator)
|
||||
author = Author.first
|
||||
assert_equal author, Author.find_by(id: decorator.new(author))
|
||||
assert_equal author, Author.find_by(id: [decorator.new(author)])
|
||||
end
|
||||
|
||||
def test_find_with_list_of_ar
|
||||
author = Author.first
|
||||
authors = Author.find([author.id])
|
||||
|
|
Loading…
Reference in New Issue