From 1facce6c244713bb88e4ed70222f0d42b30736de Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 21 Jan 2006 23:40:20 +0000 Subject: allow has_many :through to work with custom :foreign key (closes #3422) [Rick Olson] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3456 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_record/associations/has_many_through_association.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/associations/has_many_through_association.rb') 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 d3b6707e36..de0854a8cd 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -62,7 +62,6 @@ module ActiveRecord def construct_conditions through_reflection = @owner.class.reflections[@reflection.options[:through]] - through_foreign_classname = ActiveRecord::Base.send(:class_name_of_active_record_descendant, @owner.class).to_s if through_reflection.options[:as] conditions = @@ -72,7 +71,7 @@ module ActiveRecord else conditions = "#{@reflection.klass.table_name}.#{@reflection.klass.primary_key} = #{through_reflection.table_name}.#{@reflection.klass.to_s.foreign_key} " + - "AND #{through_reflection.table_name}.#{through_foreign_classname.foreign_key} = #{@owner.quoted_id}" + "AND #{through_reflection.table_name}.#{through_reflection.primary_key_name} = #{@owner.quoted_id}" end conditions << " AND (#{interpolate_sql(sanitize_sql(@reflection.options[:conditions]))})" if @reflection.options[:conditions] -- cgit v1.2.3