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
[ci skip] define_model_callbacks
only exist in active model
#25342
[ci skip] define_model_callbacks
only exist in active model
#25342
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @eileencodes (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I'm wondering if it would be worth mentioning in the docs that calling define_callbacks :validate
set_callback :validate, ->(o) { o.returns_true }
define_callbacks :validate # This removes the previous callback we set |
^ Do you want to submit that as a separate PR for that? |
If you think it's valuable then I can add it in this PR. I ran into the problem, having a line in the doc mentioning it would have probably saved me a headache 😅 Edit: Added an entry in the doc. Will remove commit if you dislike it |
effdbd8
to
24e9328
Compare
# `!`, `?` or `=`. | ||
# | ||
# Calling `define_callbacks` multiple times with the same +names+ will | ||
# overwrite previous callback set with `set_callback`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previous callback --> previous callbacks
set --> registered (since we using set_
two words down the line 😉)
Seems reasonable to me. Added a comment with one or two small grammar changes :) |
- Also added a note when calling multiple time `define_callbacks`
24e9328
to
3da701d
Compare
thanks for your help 😸 |
@@ -736,8 +736,13 @@ def reset_callbacks(name) | |||
# | |||
# would call <tt>Audit#save</tt>. | |||
# | |||
# NOTE: +method_name+ passed to `define_model_callbacks` must not end with | |||
# ===== Notes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you follow this from somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added 2 more =
to be consistent with the ===== Option
above
Thanks @Edouard-chin ! |
Small documentation fix