-1

In my case, update_attributes is not updating the instance with the latest value but update_attributes! is updating the new value.

SaiK
  • 3
  • 2
  • 3
    Possible 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
  • 1
    Your 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 Answers1

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 calls save! instead of save, so an exception is raised if the record is invalid and saving will fail.

arieljuod
  • 15,460
  • 2
  • 25
  • 36