-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can no longer validate presence of an association after upgrade to Rails 4.1 #16684
Comments
@taryneast thank you for your report. Can you attach an executable test-case to reproduce the error? You can use this script as a starting point. |
We attempted to reproduce this issue for Rails 4.0.3, but this gist fails: |
cool, thanks guys, I'll have a go at making a new testable set based on your examples. I've got it running in Rails 4.0 - just need to make sure it breaks (the same way) in Rails 4.1 |
Ok, here's the gist. It consistently passes on Rails 4.0 and fails on 4.1. |
I pushed a fix (will backport it to @taryneast thank you for reporting. |
Closes #16684. This is achieved by always generating `GeneratedAssociationMethods` when `ActiveRecord::Base` is subclassed. When some of the included modules of `ActiveRecord::Base` were reordered this behavior was broken as `Core#initialize_generated_modules` was no longer called. Meaning that the module was generated on first access. Conflicts: activerecord/test/cases/attribute_methods/read_test.rb
Closes rails#16684. This is achieved by always generating `GeneratedAssociationMethods` when `ActiveRecord::Base` is subclassed. When some of the included modules of `ActiveRecord::Base` were reordered this behavior was broken as `Core#initialize_generated_modules` was no longer called. Meaning that the module was generated on first access.
The
create!
fails withValidation failed: Recipient can't be blank
even though I'm clearly passing a recipient.This worked in Rails 4.0.
I can see nothing in the upgrade notes or the release notes for 4.1 about what changed to make this stop working.
What changed?
Why did it change?
What can I do to make it work again?
The text was updated successfully, but these errors were encountered: