Could someone please explain to me the difference between the :before_save
and :before_update
Active Record callbacks in Ruby on Rails 4?
I read through the official documentation on Active Record callbacks, but I couldn't find a granular-enough explanation.
:before_save
is called everytime a record is inserted/updated in the database. So it is called on every save whether its a new record or existing record.
:before_update
is called only when the record is updated & never on new record.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With