rails/rails — pull request #16342 by itsNikolay (2014-07-29 23:10:03+00:00)
Title: ActiveRecord::Reflection::AbstractReflection#join_keys is refactored to a little more clear implementation

Before:
```ruby
def join_keys(assoc_klass)
if source_macro == :belongs_to
if polymorphic?
reflection_key = association_primary_key(assoc_klass)
else
reflection_key = association_primary_key
end
reflection_foreign_key = foreign_key
else
reflection_foreign_key = active_record_primary_key
reflection_key = foreign_key
end
JoinKeys.new(reflection_key, reflection_foreign_key)
end
```
Now:
```ruby
def join_keys(assoc_klass)
reflection_key, reflection_foreign_key =
if source_macro == :belongs_to
klass = polymorphic? ? assoc_klass : nil
[association_primary_key(klass), foreign_key]
else
[foreign_key, active_record_primary_key]
end

JoinKeys.new(reflection_key, reflection_foreign_key)
end
```