Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jonleighton committed Oct 19, 2010
1 parent 915ea5e commit b00db54
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions activerecord/lib/active_record/associations.rb
Expand Up @@ -2186,9 +2186,7 @@ def join_to(relation)
# to represent the join table)
table, join_table = table

# TODO: Can join_key just be reflection.primary_key_name ?
join_key = reflection.options[:foreign_key] ||
reflection.active_record.to_s.foreign_key
join_key = reflection.primary_key_name
join_foreign_key = reflection.active_record.primary_key

relation = relation.join(join_table, join_type).on(
Expand All @@ -2199,10 +2197,8 @@ def join_to(relation)
# We've done the first join now, so update the foreign_table for the second
foreign_table = join_table

# TODO: Can foreign_key be reflection.association_foreign_key?
key = reflection.klass.primary_key
foreign_key = reflection.options[:association_foreign_key] ||
reflection.klass.to_s.foreign_key
foreign_key = reflection.association_foreign_key
end
else
case reflection.source_reflection.macro
Expand Down

0 comments on commit b00db54

Please sign in to comment.