Disabling callbacks in Rails 3
leenaMay 1, 2011
It is common requirement to disable the callbacks like after_save, after_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:
User.skip_callback("create",:after,:send_confirmation_email)
The above will skip the send_confirmation_email callback fired on after_create.
To set the callback back:
User.set_callback("create",:after,:send_confirmation_email)