Devise: Don't send confirmation email when sign-up?

Created on 30 Jul 2016  路  5Comments  路  Source: heartcombo/devise

I want let user confirm their email, so I add confirmable into migration and model.
but I don't want send email during sign-up process
I want let user manually send confirm email by click a button

I can't find offcial document about how to disable email sending during sign-up
and I have try several solution from StackOverflow and Google.

not working,
Still send email everytime when I signup
image

rails 4.2.6
devise 4.2.0

Thanks :)

Most helpful comment

@1c7 Have you tried overriding this method in your Model?

def send_confirmation_notification?
  false
end

link to method: https://github.com/plataformatec/devise/blob/master/lib/devise/models/confirmable.rb#L158

All 5 comments

@1c7 Have you tried overriding this method in your Model?

def send_confirmation_notification?
  false
end

link to method: https://github.com/plataformatec/devise/blob/master/lib/devise/models/confirmable.rb#L158

@abevoelker
Thanks for comment
I can't try your solution now, sorry.
I already remove relate code, I decide to do email confirmation myself.

because seem like if use devise, even I solve this current problem,

later the other problem would be how to send email in background when using devise,
and seem like there are no easy way to do it.
So I decide just implement email conformation & send email in background all by myself.
make code more readable.

@1c7 Not sure where exactly you are facing issue cause Devise has very straight forward way of sending email notifications. for example in your case you want to send a confirmation email when user clicks a button. once they do, you can use

Devise::Mailer.confirmation_instructions(@user).deliver_later 

to shoot confirmation email. they have recently merged this feature where you can simply send email in the background using deliver_later. Thats great you wrote your own solution but may be that's not DRY in a sense that Devise already has simple answer to it.

@abhinaykumar Thanks for long reply, very helpful.

@1c7 Have you tried overriding this method in your Model?

def send_confirmation_notification?
  false
end

link to method: plataformatec/devise:lib/devise/models/confirmable.rb@master#L158

While you can certainly override this method, the officially documented/recommended way of skipping sending a confirmation email during signup is by calling user.skip_confirmation_notification! before saving the user.

Was this page helpful?
0 / 5 - 0 ratings