association methods are now generated in modules #3636
jonleighton merged 6 commits into rails:master from joshsusser:master
Nov 29, 2011
Commits on Nov 16, 2011
Nov 15, 2011
Instead of generating association methods directly in the model class, they are generated in an anonymous module which is then included in the model class. There is one such module for each association. The only subtlety is that the generated_attributes_methods module (from ActiveModel) must be forced to be included before association methods are created so that attribute methods will not shadow association methods.
Commits on Nov 27, 2011
This change uses Module.redefine_method as defined in ActiveSupport. Making Module.define_method public would be as clean in the code, and would also emit warnings when redefining an association. That is pretty messy given current tests, so I'm leaving it for someone else to decide what approach is better.
Commits on Nov 29, 2011