diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2018-09-26 11:40:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-26 11:40:55 -0400 |
commit | 36440720689c07eb2c45d9d39005814e71e387a4 (patch) | |
tree | b162f17d2a20972e188fb005abd62ca0bd7afe16 /activerecord/lib | |
parent | a592e87a278cec10569d854dd5ece22179471bc0 (diff) | |
parent | 92e024c6abac16cc5a96ec948c381bfa3f0a22df (diff) | |
download | rails-36440720689c07eb2c45d9d39005814e71e387a4.tar.gz rails-36440720689c07eb2c45d9d39005814e71e387a4.tar.bz2 rails-36440720689c07eb2c45d9d39005814e71e387a4.zip |
Merge pull request #31819 from bpohoriletz/master
If association is a hash-like object preloading fails
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb index d4d1b2a282..a8f94b574d 100644 --- a/activerecord/lib/active_record/associations/preloader.rb +++ b/activerecord/lib/active_record/associations/preloader.rb @@ -98,12 +98,11 @@ module ActiveRecord # Loads all the given data into +records+ for the +association+. def preloaders_on(association, records, scope, polymorphic_parent = false) - case association - when Hash + if association.respond_to?(:to_hash) preloaders_for_hash(association, records, scope, polymorphic_parent) - when Symbol + elsif association.is_a?(Symbol) preloaders_for_one(association, records, scope, polymorphic_parent) - when String + elsif association.respond_to?(:to_str) preloaders_for_one(association.to_sym, records, scope, polymorphic_parent) else raise ArgumentError, "#{association.inspect} was not recognized for preload" |