20

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.
Thilo
  • 17,565
  • 5
  • 68
  • 84
Gawyn
  • 1,156
  • 1
  • 10
  • 21

6 Answers6

43

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.

Thilo
  • 17,565
  • 5
  • 68
  • 84
  • 6
    Glad it helped. If you use bundler, you can always look at any gem's source easily with `bundle open ` to take a look around. – Thilo Nov 23 '12 at 15:35
8

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! 
toashd
  • 1,002
  • 8
  • 10
7

Use skip_confirmation! method before saving any object.

def create
  @user = User.new(params[:user])
  @user.skip_confirmation!
  @user.save!
end
Santosh
  • 1,251
  • 9
  • 15
  • I don't want to skip the confirmation. I just want Devise not to send its email, as I am sending my own. – Gawyn Nov 23 '12 at 15:15
  • @CristianPlanasGonzález skip_confirmation! will only skip devise confirmation method not your own confirmation method. Please try this it will work. – Santosh Nov 23 '12 at 15:31
  • skip_confirmation! sets the confirmed_at attribute to Time.now, basically confirming the user. I'm using all the Devise confirmable module, except the mail. – Gawyn Nov 23 '12 at 15:34
  • 4
    You should use `skip_confirmation_notification!`. – joost Mar 09 '15 at 12:01
2

I think just removing

:confirmable

from the user model should do it

or have you tried disabling

config/environments/development.rb

config.action_mailer.default_url_options = { :host => 'localhost:3000' }
Richlewis
  • 15,070
  • 37
  • 122
  • 283
  • I need the confirmable module because I am confirming users. I use the confirm routes that devise provides to me, and also the confirmable attributes of the User class. I just don't want Devise to send a mail, as I want to send my own. – Gawyn Nov 23 '12 at 15:01
  • ah right i see, couldnt you just modify the devise mailer to look how you want it too, seems an effort to not use the built in features? – Richlewis Nov 23 '12 at 15:05
2

I recommend you

User.skip_reconfirmation!

That is skip confirm mail and update email not to use "confirm!"

kon_yu
  • 174
  • 1
  • 2
  • 8
0

remove (:confirmable) from devise model ex:- here my devise model is User here I used like this.

class User < ActiveRecord::Base  
     devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,:omniauthable

end
Moumit
  • 8,314
  • 9
  • 55
  • 59
Govind shaw
  • 407
  • 4
  • 12