Disabling callbacks in Rails 3


May 1, 2011

It is common requirement to disable the callbacks like after_saveafter_create etc while importing/migrating data. One way to avoid this is by directly importing the data into DB using a command like mysqlimport. But by doing that, the Rails validations etc will not work. We can disable the callbacks using the skip_callback method.  For eg:


The above will skip the send_confirmation_email callback fired on after_create.

To set the callback back: