Please sign in to comment.
association methods are now generated in modules
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.
- Loading branch information...
Showing with 43 additions and 30 deletions.
- +5 −5 activerecord/lib/active_record/associations/builder/association.rb
- +3 −3 activerecord/lib/active_record/associations/builder/belongs_to.rb
- +2 −2 activerecord/lib/active_record/associations/builder/collection_association.rb
- +4 −8 activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
- +3 −3 activerecord/lib/active_record/associations/builder/has_many.rb
- +5 −6 activerecord/lib/active_record/associations/builder/has_one.rb
- +3 −3 activerecord/lib/active_record/associations/builder/singular_association.rb
- +6 −0 activerecord/lib/active_record/attribute_methods.rb
- +12 −0 activerecord/test/cases/associations_test.rb