diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-05 17:11:49 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-05 17:11:49 +0000 |
commit | 81014da84c9ae4dacb70287ff6f509d7a40cc0ae (patch) | |
tree | d6c70e6f4733de0d863dbe72d5a646aa7c75143c /activerecord | |
parent | a5cffb3aeff830ae139c9b3b8cd53f30812f073c (diff) | |
download | rails-81014da84c9ae4dacb70287ff6f509d7a40cc0ae.tar.gz rails-81014da84c9ae4dacb70287ff6f509d7a40cc0ae.tar.bz2 rails-81014da84c9ae4dacb70287ff6f509d7a40cc0ae.zip |
Use :foreign_key option if specified on the association
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1096 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 8bc15a213b..4413a79a40 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -655,10 +655,10 @@ module ActiveRecord case reflection.macro when :has_many, :has_one sql << " LEFT JOIN #{reflection.klass.table_name} ON " + - "#{reflection.klass.table_name}.#{table_name.classify.foreign_key} = #{table_name}.#{primary_key} " + "#{reflection.klass.table_name}.#{reflection.options[:foreign_key] || table_name.classify.foreign_key} = #{table_name}.#{primary_key} " when :belongs_to sql << " LEFT JOIN #{reflection.klass.table_name} ON " + - "#{reflection.klass.table_name}.#{reflection.klass.primary_key} = #{table_name}.#{reflection.klass.table_name.classify.foreign_key} " + "#{reflection.klass.table_name}.#{reflection.klass.primary_key} = #{table_name}.#{reflection.options[:foreign_key] || reflection.klass.table_name.classify.foreign_key} " end end |