diff options
author | thedarkone <thedarkone2@gmail.com> | 2014-03-30 20:23:50 +0200 |
---|---|---|
committer | thedarkone <thedarkone2@gmail.com> | 2014-03-30 20:23:50 +0200 |
commit | de32d972bfde8871f7c1a4621f2223ea9b6715b2 (patch) | |
tree | bff561681218b1362952fd93151f6b2833e7dbc0 /activerecord/lib/active_record | |
parent | 593e6978656e3dd07683d2add186b72c9fbad683 (diff) | |
download | rails-de32d972bfde8871f7c1a4621f2223ea9b6715b2.tar.gz rails-de32d972bfde8871f7c1a4621f2223ea9b6715b2.tar.bz2 rails-de32d972bfde8871f7c1a4621f2223ea9b6715b2.zip |
Fix polymorphic preloads on NOT NULL _type columns.
Defer to Association#klass instead of having a custom/duplicate code.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader.rb | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb index 83637a0409..e6485b2b0c 100644 --- a/activerecord/lib/active_record/associations/preloader.rb +++ b/activerecord/lib/active_record/associations/preloader.rb @@ -144,7 +144,7 @@ module ActiveRecord reflection_records.each_with_object({}) do |(reflection, r_records),h| h[reflection] = r_records.group_by { |record| - association_klass(reflection, record) + record.association(association).klass } end end @@ -163,15 +163,6 @@ module ActiveRecord "perhaps you misspelled it?" end - def association_klass(reflection, record) - if reflection.macro == :belongs_to && reflection.options[:polymorphic] - klass = record.read_attribute(reflection.foreign_type.to_s) - klass && klass.constantize - else - reflection.klass - end - end - class AlreadyLoaded attr_reader :owners, :reflection |