How to save a model without running callbacks in Rails

I believe what you are asking for can be achieved with ActiveSupport::Callbacks. Have a look at set_callback and skip_callback.

In order to “force callbacks to get called even if you made no changes to the record”, you need to register the callback to some event e.g. save, validate etc..

set_callback :save, :before, :my_before_save_callback

To skip the before_save callback, you would do:

Survey.skip_callback(:save, :before, :calculate_average). 

Please reference the linked ActiveSupport::Callbacks on other supported options such as conditions and blocks to set_callback and skip_callback.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)