-
-
Notifications
You must be signed in to change notification settings - Fork 910
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
Check for belongs_to asks for explicit "required: true" when using before_validation #1154
Comments
Hey @mccard. Thanks for the detailed report and sorry it took so long for me to get back to you on this. The reason why the matcher is failing is that your I think I mentioned this in another issue, but I'm wondering now if I need to add an additional qualifier that tells the matcher not to worry about the presence validation check. Something like |
What about unsetting the association before running the presence validation? I can provide a PR if that would be useful. |
@johnam Yup, that's what the matcher is doing already. The problem is that no matter how the matcher changes the association, the model is overwriting it before the presence validation gets run. |
I've added a new shoulda-matchers/lib/shoulda/matchers/active_record/association_matcher.rb Lines 275 to 302 in 707d87d
|
Sorry for my English. When I tries use without_presence_validation i have exception
|
Sorry. I use |
@vesh95 It looks like you're using |
rails version
5.1+
shoulda-matchers version
gem 'shoulda-matchers', '4.0.0.rc1'
Error
Steps to reproduce
Note
It continues to happen if I set the
required: true
The text was updated successfully, but these errors were encountered: