aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJim Remsik and Tim Pope <dev+bigtiger+tpope@hashrocket.com>2009-03-09 13:42:51 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-03-09 13:43:28 +0000
commit1e6c50e21bdb8c99116a7dc6921ef3eb4ed9531a (patch)
tree1658deea2328ef01332fd8589dfaa461f4186d87 /activerecord/lib
parent1ab2ff58eddee8ac523624dd097424f9a760ad8b (diff)
downloadrails-1e6c50e21bdb8c99116a7dc6921ef3eb4ed9531a.tar.gz
rails-1e6c50e21bdb8c99116a7dc6921ef3eb4ed9531a.tar.bz2
rails-1e6c50e21bdb8c99116a7dc6921ef3eb4ed9531a.zip
Ensure has_many :through works with changed primary keys [#736 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb2
1 files changed, 1 insertions, 1 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 23fe76de2e..1c091e7d5a 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -150,7 +150,7 @@ module ActiveRecord
end
else
reflection_primary_key = @reflection.source_reflection.primary_key_name
- source_primary_key = @reflection.klass.primary_key
+ source_primary_key = @reflection.through_reflection.klass.primary_key
if @reflection.source_reflection.options[:as]
polymorphic_join = "AND %s.%s = %s" % [
@reflection.quoted_table_name, "#{@reflection.source_reflection.options[:as]}_type",