Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Devise confirmable mails

Recently I added the confirmable module to my User class. I already have a quite nice mailing system (Sidekiq, Sendgrid...) in my app, so I created my own "confirm account" mail. The problem now is to disable Devise from sending its default email. Is there any way to completely disable the Devise mailing system?

Added:

  • I want to maintain the confirmable module, as I am using its attributes and routes.
  • I can't use skip_confirmation! because I want the users to confirm their account.
  • I just want to disable Devise mails.
like image 663
Gawyn Avatar asked Nov 23 '12 14:11

Gawyn


2 Answers

Use the source, Luke:

# lib/devise/models/confirmable.rb

# A callback method used to deliver confirmation
# instructions on creation. This can be overriden
# in models to map to a nice sign up e-mail.
def send_on_create_confirmation_instructions
  send_devise_notification(:confirmation_instructions)
end

So override this method in your model to do nothing.

like image 79
Thilo Avatar answered Oct 14 '22 21:10

Thilo


Try overriding the following devise method in your model:

def confirmation_required?
  !confirmed?
end

or use skip_confirmation!:

user = User.new(params) 
user.skip_confirmation! 
user.save! 
like image 39
toashd Avatar answered Oct 14 '22 23:10

toashd