From 4debc86bd329d31360272ed15459cde3b9af3a10 Mon Sep 17 00:00:00 2001 From: Lauro Caetano Date: Wed, 23 Apr 2014 23:51:00 -0300 Subject: Fix polymorphic eager load with foreign_key as String. The foreign_key could be `String` and just doing `owners_map[owner_key]` could return `nil`. To prevent this bug, we should `to_s` both keys if their types are different. Fixes #14734. --- activerecord/test/models/comment.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index ea261ac9ec..3cb32d9346 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -7,6 +7,9 @@ class Comment < ActiveRecord::Base scope :created, -> { all } belongs_to :post, :counter_cache => true + belongs_to :author, polymorphic: true + belongs_to :resource, polymorphic: true + has_many :ratings belongs_to :first_post, :foreign_key => :post_id -- cgit v1.2.3