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

Remove update_attribute. #6738

Merged
merged 1 commit into from
Jun 14, 2012
Merged

Remove update_attribute. #6738

merged 1 commit into from
Jun 14, 2012

Conversation

steveklabnik
Copy link
Member

Historically, update_attribute and update_attributes are similar, but
with one big difference: update_attribute does not run validations.
These two methods are really easy to confuse given their similar
names. Therefore, update_attribute is being removed in favor of
update_column.

See the thread on rails-core here:
https://groups.google.com/forum/?fromgroups#!topic/rubyonrails-core/BWPUTK7WvYA

Historically, update_attribute and update_attributes are similar, but
with one big difference: update_attribute does not run validations.
These two methods are really easy to confuse given their similar
names. Therefore, update_attribute is being removed in favor of
update_column.

See the thread on rails-core here:
https://groups.google.com/forum/?fromgroups#!topic/rubyonrails-core/BWPUTK7WvYA
@ghost ghost assigned fxn Jun 14, 2012
fxn added a commit that referenced this pull request Jun 14, 2012
@fxn fxn merged commit 776fd51 into rails:master Jun 14, 2012
@mhuggins
Copy link

Nice! Always found this confusing and questioned the reasoning behind the difference in the first place.

@laserlemon
Copy link
Contributor

I don't think that update_column and update_attribute are interchangeable. Validations are a major difference between update_attribute and update_attributes but as I understand, update_attribute still goes through AR's normal save lifecycle including dirty tracking and callbacks while update_column does not.

@fxn
Copy link
Member

fxn commented Jun 15, 2012

Right, nobody claims that. Those differences are explained in the deprecation warning in 3.2, and in the CHANGELOG.

@steveklabnik
Copy link
Member Author

#6739 is the one with the warning. :)

@dideler
Copy link

dideler commented Apr 4, 2014

I'm confused. The update_attribute method is still documented for Rails 4 and it works when I try it in console. I see a lot of places saying that this method has been removed (e.g. the Rails community style guide). I'm guessing it's been re-added since?

@rafaelfranca
Copy link
Member

It was not removed yet. In fact it was but we reverted to better evaluate its usage.

Good725 added a commit to Good725/style-guide-rails that referenced this pull request Feb 19, 2020
The method was removed about 2 years ago, but that change has since been reverted: rails/rails#6738 (comment)

I also linked the method to its documentation on the RoR API docs: http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attribute
goldapple911 added a commit to goldapple911/rails-style-guide that referenced this pull request Aug 15, 2023
The method was removed about 2 years ago, but that change has since been reverted: rails/rails#6738 (comment)

I also linked the method to its documentation on the RoR API docs: http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attribute
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.

9 participants