Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Devise skip confirmation notification before save

Tags:

In Rails 4.2.0, I am using the Devise gem for authentication - devise 3.4.1.

The confirmation email is sent as soon as a user is created. We need to skip this confirmation email and send a custom email with the confirmation link. Please help me to solve this issue.

:confirmable is used in the User model.

like image 895
Shruthi R Avatar asked May 27 '15 07:05

Shruthi R


1 Answers

You can try this

@user.skip_confirmation! @user.save 

Call skip_confirmation! before saving the user record.

To skip the confirmation notification only you can use skip_confirmation_notification!

@user.skip_confirmation_notification! @user.save 

Hope this helps!


In Addition

if you wish to skip confirmation on the same line without creating a variable and you do not need to confirm that particular User, for example in seeds.rb:

User.create(email: "#{role_name}@example.com",             password: 'password',             password_confirmation: 'password',             confirmed_at: Time.now.utc, # skip confirmation) 

or

If you just want to override the default email template, then you can run

rails generate devise:views -v registrations confirmations 

It will generate the default views for confirmations then you can override it according to your need.

like image 135
Rajdeep Singh Avatar answered Sep 28 '22 12:09

Rajdeep Singh