rails/rails — pull request #15630 by eileencodes (2014-06-11 02:09:03+00:00)
Title: begin refactoring add_constraints by moving join keys

add_constraints is complicated and difficult to read code. This is the beginning of a long process of refactoring. First step: moved the join keys out of AssociationScope and into Reflection.

We then don't need to call `reflection` because now reflection is `self`.

`foreign_key` must be named something else because reflection already has a `foreign_key` method and when passed into `JoinKeys` it was getting the wrong assignment. `reflection_foreign_key` seemed to be an appropriate name. I also named `key` `reflection_key` to match `reflection_foreign_key`.

cc/ @tenderlove