1

This might be quite simple, but I am tearing my hair out. I have a script that I want to run on a daily basis, the script updates a ton of records( across 20 different models) and I dont really care about maintaining an audit trail of these mass changes( or want to trigger 1000's of notifications). I really need a way of disabling acts_as_audited and action mailer temporarily, running the script and then re enabling them both.

Is there a simple way of doing this?

I am using ree/rails 2.3

Faraaz Khan
  • 701
  • 2
  • 8
  • 13
  • 1
    ok so I figured out how to disable auditing, its simply class.disable_auditing and class.enable_auditing. Still looking for help on ActionMailer though, we are using the gmail confirmation, so i dont have a perform_deliveries option in my config file ( I would not want to modify the config file in any case, need something that can disable and reenable notifications at runtime)...anyone? – Faraaz Khan Sep 11 '11 at 07:02

1 Answers1

1

Figured it out finally, this blog post: http://blog.viarails.net/2009/1/29/disabling-callbacks-in-an-activerecord-data-migration and this stackoverflow question helped How can I avoid running ActiveRecord callbacks?.

TO take it a step further you can also disable specific methods(lets say a notification that is done before_save) that are being called in the callback chain by doing this YourModel.before_save_callback_chain.select {|m| m.method == :your_notification_method_symbol}.clear

Just posting this so others may find it...enjoy!

Community
  • 1
  • 1
Faraaz Khan
  • 701
  • 2
  • 8
  • 13