diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-22 02:20:37 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-22 02:20:37 +0000 |
commit | 5c1be2812ddc81a3ac5b65c8a461a9622e41b31c (patch) | |
tree | b97565500852ab3994059b455725225d3d6bd2f0 /activerecord/lib/active_record | |
parent | f921a96e8506ca5d376a83f06b45ffd8df737fa7 (diff) | |
download | rails-5c1be2812ddc81a3ac5b65c8a461a9622e41b31c.tar.gz rails-5c1be2812ddc81a3ac5b65c8a461a9622e41b31c.tar.bz2 rails-5c1be2812ddc81a3ac5b65c8a461a9622e41b31c.zip |
has_one :through supports :source_type. Fix up some tests. References #4756.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9075 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/association_preload.rb | 9 | ||||
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 2 |
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 |