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
Document ActiveModel::Validations#validation_context #46391
Comments
Hi, Thanks for opening an issue here. I think |
Thank you for the response:) Yes, I found the documentation for the Looking at this part of the code, I see that only the setter is made private, and the getter could still be called publicly. rails/activemodel/lib/active_model/validations.rb Lines 48 to 49 in cfa9c9f
And this method could be used in situations like this #21957 (comment) (see "How to do" section), because there's still no but this looks kinda workaround-ish to me so I wasn't sure if it should be documented as a public method or not. |
Background: To run validations except in a certain context, we need to either 1. explicitly pass all validation contexts to the `on` option 2. access undocumented `validation_context` Option 1 is error-prone. Additionally, adding the opposite behavior of `on` was rejected rails#30710. Solution: Document `ActiveModel#validation_context` to make it clear that the API is public. Close rails#46391.
The
ActiveModel::Validations#validation_context
seems to be a public method, but it is not documented on the https://api.rubyonrails.org/. If it is correct to use this publicly, shouldn't it be documented?I was trying to do something like this comment but could not find the documentation...
Thanks.
The text was updated successfully, but these errors were encountered: