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
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
If you just want to skip sending the email but not doing confirmation, use:
# Skips sending the confirmation/reconfirmation notification email after_create/after_update. Unlike
# #skip_confirmation!, record still requires confirmation.
@user.skip_confirmation_notification!
If you don't want to call this in your model with a callback overwrite this method:
def send_confirmation_notification?
false
end
You can also simply add the following line of code in your controller before creating the new user:
@user.skip_confirmation!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With