Search code examples
rubyemaildeviseconfirmation

Devise: Is it possible to NOT send a confirmation email in specific cases ? (even when confirmable is active)


Here is my situation, I use devise to allow users to create account on my site and manage their authentication. During the registration process I allow customers to change some options, leading to an actually different account being created but still based on the same core user resource. I would like to choose not to send a confirmation email for some of those account types. I don't care if the account do not get confirmed and user cannot log in, that's ok, no pb with that. How would I go about doing that ? Thanks, Alex


Solution

  • Actually it's quite easy once I dig a little deeper. Just override one method in your User model (or whatever you are using):

        # Callback to overwrite if confirmation is required or not.
        def confirmation_required?
          !confirmed?
        end
    

    Put your conditions and job's done !

    Alex