I\'m using Devise to allow user signup as-well-as using my own user admin to create users manually. When I create a user in the admin, Devise sends a confirmati
We do this in one of our apps. You can tell Devise NOT to automatically deliver the confirmation like this:
@user.skip_confirmation!
And then later, you can do
Devise::Mailer.confirmation_instructions(@user).deliver
For Rails 2.x you'd do something like:
DeviseMailer.deliver_confirmation_instructions(@user)
There is now the devise-async project:
I just spent some time looking into this, basically you just need to add this and setup delayed_job.
def send_confirmation_instructions
generate_confirmation_token! if self.confirmation_token.nil?
::Devise.mailer.delay.confirmation_instructions(self)
end
Add it in your user model as protected method to override the devise one in confirmable. Also, note the gem was just updated to add a new method to be overridden on create that sends the confirmation instructions.
There's now an easier way (was added back in v2.2.4)
Devise's confirmable module now includes the perfect skip_confirmation_notification! method which allows for a cleaner solution:
@user = User.new params[:user]
@user.skip_confirmation_notification!
@user.save
# ... do stuff, then later...
Devise::Mailer.confirmation_instructions(@user).deliver
Do you use delayed job ? It allows you to define single methods for delayed run.
@user.skip_confirmation! confirms the user, so the user can log in without using the confirmation.
This works for me in devise 3.5
Stop devise to send confirmation email while creating user.
@user.skip_confirmation_notification!
Send confirmation instructions later
@user.send_confirmation_instructions