diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-03-19 16:13:52 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-03-19 16:13:52 +0000 |
commit | ea25e246e0ac796446f025bb369076adbcb390ab (patch) | |
tree | df507bd6608e6209f0f6b4e759c666fff3417321 /activerecord/lib/active_record/associations | |
parent | fcd4c9529c071d3c77cbf57fe733869da0d3fde8 (diff) | |
download | rails-ea25e246e0ac796446f025bb369076adbcb390ab.tar.gz rails-ea25e246e0ac796446f025bb369076adbcb390ab.tar.bz2 rails-ea25e246e0ac796446f025bb369076adbcb390ab.zip |
Quit ignoring default :include options in has_many :through calls [Mark James]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3974 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_through_association.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index 1baac52cdd..4e0b6f1c98 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -24,9 +24,10 @@ module ActiveRecord options[:order] = @reflection.options[:order] end - options[:select] = construct_select - options[:from] = construct_from - options[:joins] = construct_joins + options[:select] = construct_select + options[:from] = construct_from + options[:joins] = construct_joins + options[:include] ||= @reflection.source_reflection.options[:include] merge_options_from_reflection!(options) @@ -57,7 +58,8 @@ module ActiveRecord :joins => construct_joins, :order => @reflection.options[:order], :limit => @reflection.options[:limit], - :group => @reflection.options[:group] + :group => @reflection.options[:group], + :include => @reflection.options[:include] || @reflection.source_reflection.options[:include] ) end @@ -96,7 +98,7 @@ module ActiveRecord end "INNER JOIN %s ON %s.%s = %s.%s #{@reflection.options[:joins]}" % [ - @owner.class.reflections[@reflection.options[:through]].table_name, + @reflection.through_reflection.table_name, @reflection.table_name, reflection_primary_key, @reflection.through_reflection.table_name, source_primary_key ] |