I'm using restful_authentication in my app. I'm creating a set of default users using a rake task, but every time I run the task an activation email is sent out because of the observer associated with my user model. I'm setting the activation fields when I create the users, so no activation is necessary.
Anyone know of an easy way to bypass observers while running a rake task so that no emails get sent out when I save the user?
Thanks.
Disabling observers for Rails 3 it's simple:
There isn't a straightforward way to disable observers that I know of, but it sounds possible to add logic to your observer to not send an email when the activation code is set...
More on this:
Disabling Callbacks in Rails 3
As a flag for the observer I like to define a class accessor called "disabled" so it reads like this:
I put it as a condition in the sensitive callbacks
and I just turn the flag on when needed
Another one you can try (rails 3)
You can take the method off the observer;
Will stop the :after_create on MessageObserver by removing it.