Skip to content
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

Merged
merged 1 commit into from Jun 10, 2016

Conversation

Edouard-chin
Copy link
Member

Small documentation fix

@rails-bot
Copy link

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.

@Edouard-chin
Copy link
Member Author

I'm wondering if it would be worth mentioning in the docs that calling define_callbacks twice will actually remove the callbacks already set as it's creating a new instance of CallbackChain

define_callbacks :validate

set_callback :validate, ->(o) { o.returns_true }
define_callbacks :validate # This removes the previous callback we set

@maclover7
Copy link
Contributor

^ Do you want to submit that as a separate PR for that?

@Edouard-chin
Copy link
Member Author

Edouard-chin commented Jun 10, 2016

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

# `!`, `?` or `=`.
#
# Calling `define_callbacks` multiple times with the same +names+ will
# overwrite previous callback set with `set_callback`.
Copy link
Contributor

@maclover7 maclover7 Jun 10, 2016

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 😉)

@maclover7
Copy link
Contributor

Seems reasonable to me. Added a comment with one or two small grammar changes :)

- Also added a note when calling multiple time `define_callbacks`
@Edouard-chin
Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vipulnsward vipulnsward merged commit cb4d18d into rails:master Jun 10, 2016
@vipulnsward
Copy link
Member

Thanks @Edouard-chin !

@Edouard-chin Edouard-chin deleted the callbacks-wrong-method-name branch June 11, 2016 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants