diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2008-08-25 23:20:10 +0100 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-25 21:23:15 -0700 |
commit | 2dbda11945507a0541d61d13b8c564121c1cd362 (patch) | |
tree | fb388c1f8de151e890045146d11dbfe0849bd0fa /activerecord/lib | |
parent | 172606e21f54fea39af68ede5f55a43deaf3ac68 (diff) | |
download | rails-2dbda11945507a0541d61d13b8c564121c1cd362.tar.gz rails-2dbda11945507a0541d61d13b8c564121c1cd362.tar.bz2 rails-2dbda11945507a0541d61d13b8c564121c1cd362.zip |
Implement old-skool eagerloading for has_one :through
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index b9039ce996..46b79c5a0d 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1974,7 +1974,7 @@ module ActiveRecord @aliased_join_table_name = aliased_table_name_for(reflection.options[:join_table], "_join") end - if reflection.macro == :has_many && reflection.options[:through] + if [:has_many, :has_one].include?(reflection.macro) && reflection.options[:through] @aliased_join_table_name = aliased_table_name_for(reflection.through_reflection.klass.table_name, "_join") end end @@ -1998,7 +1998,7 @@ module ActiveRecord ] when :has_many, :has_one case - when reflection.macro == :has_many && reflection.options[:through] + when reflection.options[:through] through_conditions = through_reflection.options[:conditions] ? "AND #{interpolate_sql(sanitize_sql(through_reflection.options[:conditions]))}" : '' jt_foreign_key = jt_as_extra = jt_source_extra = jt_sti_extra = nil |