From ea25e246e0ac796446f025bb369076adbcb390ab Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Sun, 19 Mar 2006 16:13:52 +0000 Subject: 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 --- .../associations/has_many_through_association.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record/associations') 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 ] -- cgit v1.2.3