Skip to content
Browse files

Fixed problem with eager loading when using a has_and_belongs_to_many…

… association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1516 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent e15207f commit 1bb676b6c0fd5f181e1b0b155be6bc6ffeb67d02 @dhh dhh committed
Showing with 3 additions and 1 deletion.
  1. +2 −0 activerecord/CHANGELOG
  2. +1 −1 activerecord/lib/active_record/associations.rb
View
2 activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed problem with eager loading when using a has_and_belongs_to_many association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl]
+
* Fixed Base#find to honor the documentation on how :joins work and make them consistent with Base#count #1405 [pritchie@gmail.com]. What used to be:
Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1'
View
2 activerecord/lib/active_record/associations.rb
@@ -809,7 +809,7 @@ def association_join(reflection)
"#{reflection.options[:join_table]}.#{reflection.options[:foreign_key] || table_name.classify.foreign_key} = " +
"#{table_name}.#{primary_key} " +
" LEFT OUTER JOIN #{reflection.klass.table_name} ON " +
- "#{reflection.options[:join_table]}.#{reflection.options[:associated_foreign_key] || reflection.klass.table_name.classify.foreign_key} = " +
+ "#{reflection.options[:join_table]}.#{reflection.options[:association_foreign_key] || reflection.klass.table_name.classify.foreign_key} = " +
"#{reflection.klass.table_name}.#{reflection.klass.primary_key} "
when :has_many, :has_one
" LEFT OUTER JOIN #{reflection.klass.table_name} ON " +

0 comments on commit 1bb676b

Please sign in to comment.
Something went wrong with that request. Please try again.