diff options
author | Lauro Caetano <laurocaetano1@gmail.com> | 2014-04-23 23:51:00 -0300 |
---|---|---|
committer | Lauro Caetano <laurocaetano1@gmail.com> | 2014-05-20 23:26:51 -0300 |
commit | 4debc86bd329d31360272ed15459cde3b9af3a10 (patch) | |
tree | 2743821dedf9539da64989fc9e9e79b4e1405d75 /activerecord/test/models | |
parent | b17f6e6877162648936c32e62c58305861beaf70 (diff) | |
download | rails-4debc86bd329d31360272ed15459cde3b9af3a10.tar.gz rails-4debc86bd329d31360272ed15459cde3b9af3a10.tar.bz2 rails-4debc86bd329d31360272ed15459cde3b9af3a10.zip |
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.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/comment.rb | 3 |
1 files changed, 3 insertions, 0 deletions
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 |