In my case, update_attributes is not updating the instance with the latest value but update_attributes! is updating the new value.
Asked
Active
Viewed 873 times
-1
-
3Possible duplicate of [Why are exclamation marks used in Ruby methods?](https://stackoverflow.com/q/612189/608639) and [When do I use save!, create! and update\_attributes! in Rails?](https://stackoverflow.com/q/1761076/608639) – jww Sep 17 '18 at 18:08
-
1Your title is misleading. Do you want to know the difference between those two? or do you want to know why the behavior of those two is different in your case? Btw you need to add the related code and the log. – Pavan Sep 17 '18 at 18:12
1 Answers
1
update_attributes
and update_attributes!
are aliases of update
and update!
https://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes-21
The difference between update
and update!
is right there on the docs https://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update-21
Updates its receiver just like
update
but callssave!
instead ofsave
, so an exception is raised if the record is invalid and saving will fail.

arieljuod
- 15,460
- 2
- 25
- 36