What is the difference between: before_save and: before_update Active Record callbacks?

Can someone explain the difference between the :before_save and :before_update Active Record :before_update in Ruby on Rails 4?

I read the official documentation for Active Record callbacks, but I could not find a detailed explanation.

+11
source share
1 answer

:before_save is called every time a record is inserted / updated in the database. Thus, it is called for each save, whether it is a new record or an existing record.

:before_update is called only when a record is updated and is never written to a new record.

+26
source

Source: https://habr.com/ru/post/984728/


All Articles