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

Improve callback examples in Active Job guide #30060

Merged
merged 2 commits into from
Aug 11, 2017

Conversation

bdewater
Copy link
Contributor

@bdewater bdewater commented Aug 3, 2017

I found the AJ guides to be a bit light on the subject and noticed the examples given contradicted the advice for AR callbacks when to register callbacks with a method or a block.

The advice for symbol/block form is taken from the Active Record guides.
@rails-bot
Copy link

r? @matthewd

(@rails-bot has picked a reviewer for you, use r? to override)


```ruby
class ApplicationJob
before_enqueue do |job|
Copy link

Choose a reason for hiding this comment

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

Given "so short that it fits in a single line" I'd recommend:

before_enqueue { |job| $statsd.increment "#{job.name.underscore}.enqueue" }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks 👍 I've changed it.

@rafaelfranca rafaelfranca merged commit 3090f8f into rails:master Aug 11, 2017
@bdewater bdewater deleted the aj-callback-docs branch August 24, 2017 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants