diff options
4 files changed, 5 insertions, 17 deletions
| diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 323f25e37e..1e2d6c4f1e 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -27,16 +27,16 @@ module ActiveRecord            raise NotImplementedError          end -        # The name of the key on the model which declares the association -        def owner_key_name -          raise NotImplementedError -        end -          private            def options              reflection.options            end +          # The name of the key on the model which declares the association +          def owner_key_name +            reflection.join_foreign_key +          end +            def associated_records_by_owner(preloader)              records = load_records do |record|                owner = owners_by_key[convert_key(record[association_key_name])] diff --git a/activerecord/lib/active_record/associations/preloader/belongs_to.rb b/activerecord/lib/active_record/associations/preloader/belongs_to.rb index ae9695f26a..62df4f5530 100644 --- a/activerecord/lib/active_record/associations/preloader/belongs_to.rb +++ b/activerecord/lib/active_record/associations/preloader/belongs_to.rb @@ -7,10 +7,6 @@ module ActiveRecord          def association_key_name            options[:primary_key] || klass && klass.primary_key          end - -        def owner_key_name -          reflection.foreign_key -        end        end      end    end diff --git a/activerecord/lib/active_record/associations/preloader/has_many.rb b/activerecord/lib/active_record/associations/preloader/has_many.rb index 29a1ce099d..9ff0aa24ab 100644 --- a/activerecord/lib/active_record/associations/preloader/has_many.rb +++ b/activerecord/lib/active_record/associations/preloader/has_many.rb @@ -7,10 +7,6 @@ module ActiveRecord          def association_key_name            reflection.foreign_key          end - -        def owner_key_name -          reflection.active_record_primary_key -        end        end      end    end diff --git a/activerecord/lib/active_record/associations/preloader/has_one.rb b/activerecord/lib/active_record/associations/preloader/has_one.rb index d87abf630f..e58fa351b0 100644 --- a/activerecord/lib/active_record/associations/preloader/has_one.rb +++ b/activerecord/lib/active_record/associations/preloader/has_one.rb @@ -7,10 +7,6 @@ module ActiveRecord          def association_key_name            reflection.foreign_key          end - -        def owner_key_name -          reflection.active_record_primary_key -        end        end      end    end | 
