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

Update active_record_callbacks.md [ci skip] #35324

Merged
merged 1 commit into from Feb 19, 2019

Conversation

sharang-d
Copy link
Contributor

@sharang-d sharang-d commented Feb 19, 2019

Change 'happen' to a more technical term

@rails-bot rails-bot bot added the docs label Feb 19, 2019
Change 'happen' to a more technical term
@sharang-d sharang-d changed the title Update active_record_callbacks.md Update active_record_callbacks.md [ci skip] Feb 19, 2019
@@ -340,7 +340,7 @@ end

### Combining Callback Conditions

When multiple conditions define whether or not a callback should happen, an `Array` can be used. Moreover, you can apply both `:if` and `:unless` to the same callback.
When multiple conditions define whether or not a callback should execute, an `Array` can be used. Moreover, you can apply both `:if` and `:unless` to the same callback.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can also say 'run' instead of 'execute' as we've used on another line.

@vipulnsward vipulnsward merged commit 6b69ae5 into rails:master Feb 19, 2019
@vipulnsward
Copy link
Member

Thanks, both work better in different sentences. Can keep as is

@sharang-d sharang-d deleted the patch-2 branch February 19, 2019 11:18
@kamipo
Copy link
Member

kamipo commented Feb 19, 2019

I don't think this should be merged. We already use "happen" a lots for callbacks and validations.

# Validates that the specified attributes are blank (as defined by
# Object#blank?). Happens by default on save.

# Validates that the specified attributes are not blank (as defined by
# Object#blank?). Happens by default on save.

# {#destroy}[rdoc-ref:Persistence#destroy] come wrapped in a transaction that ensures
# that whatever you do in validations or callbacks will happen under its
# protected cover. So you can use validations to check for values that

### When Does Validation Happen?

The validation happens by performing an SQL query into the model's table,
searching for an existing record with the same value in that attribute.

validates :name, uniqueness: { scope: :year,
message: "should happen once per year" }

The `:on` option lets you specify when the validation should happen. The

option when you want to specify when the validation **should** happen. If you
want to specify when the validation **should not** happen, then you may use the
`:unless` option.

You can associate the `:if` and `:unless` options with a symbol corresponding
to the name of a method that will get called right before validation happens.

On the other hand, when multiple conditions define whether or not a validation
should happen, an `Array` can be used. Moreover, you can apply both `:if` and
`:unless` to the same validation.

@kamipo
Copy link
Member

kamipo commented Feb 19, 2019

Reverted 30016df for now.

kamipo added a commit that referenced this pull request Feb 19, 2019
This reverts commit 6b69ae5, reversing
changes made to 84bd9ad.

Reason: We already use "happen" a lots for callbacks and validations.

#35324 (comment)

[ci skip]
@vipulnsward
Copy link
Member

We already use "happen" a lots for callbacks and validations.

I see we use it for validations. For callbacks though, it just felt unnatural to read it that way, given its more referred to as "callback execution".

Before merging, I tried searching if "callback happening" is a normal term to used anywhere, did not find many examples.

Anyway happy to leave as is for now though.

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

3 participants