aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/association_preload.rb9
-rwxr-xr-xactiverecord/lib/active_record/associations.rb2
2 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb
index 0c31c85bb0..ad9b9d6488 100644
--- a/activerecord/lib/active_record/association_preload.rb
+++ b/activerecord/lib/active_record/association_preload.rb
@@ -165,8 +165,13 @@ module ActiveRecord
through_records = []
records.compact.each do |record|
proxy = record.send(through_association)
- through_records << proxy.target
- proxy.reset
+
+ if proxy.respond_to?(:target)
+ through_records << proxy.target
+ proxy.reset
+ else # this is a has_one :through reflection
+ through_records << proxy if proxy
+ end
end
through_records = through_records.flatten
else
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index aa68a42c44..068f2f9de2 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1326,7 +1326,7 @@ module ActiveRecord
def create_has_one_through_reflection(association_id, options)
options.assert_valid_keys(
- :class_name, :foreign_key, :remote, :conditions, :order, :include, :dependent, :counter_cache, :extend, :as, :through, :source
+ :class_name, :foreign_key, :remote, :conditions, :order, :include, :dependent, :counter_cache, :extend, :as, :through, :source, :source_type
)
create_reflection(:has_one, association_id, options, self)
end