diff options
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 |