-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Support a context for update_attributes / update_attributes! methods. #4026
Conversation
@@ -209,8 +209,9 @@ def update_attributes(attributes, options = {}) | |||
# The following transaction covers any possible database side-effects of the | |||
# attributes assignment. For example, setting the IDs of a child collection. | |||
with_transaction_returning_status do | |||
context = options.has_key?(:context) ? options.delete(:context) : nil |
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 think you can rewrite it like this:
context = options.delete(:context)
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.
Oops... You're right !
I'll fix and squash it.
Thanks!
Shouldn't it go to validations.rb? |
Considers your proposal, I think the easiest way to fix that next.
What do you think? |
I think the below commit is simplest way. I couldn't go to validations.rb, because I must pass options argument to the save(save!) method. |
My last comment is simplest way to support this feature, but options for assign_attributes and for save are merged ... |
@kennyj, I think it's a great idea to have |
@andreas I think some unrelated option values were passed to assign_attributes method and we should not merge option values. |
Currently, the update_attributes / update_attributes! method can't specify a validation context.
This patch allow above methods to specify the context.