Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manually send a Devise email?

I want to manually send a Devise confirmation email to a user of my app. Like this:

u = User.last
Devise::Mailer.confirmation_instructions u

but Devise's confirmation_instructions takes three parameters, the second being a token (according to the documentation) and the third being a Hash. How do I get it in order to be able to send these emails?

like image 903
rodrigoalvesvieira Avatar asked May 17 '14 22:05

rodrigoalvesvieira


1 Answers

Here’s where the ConfirmationsController sends the email:

self.resource = resource_class.send_confirmation_instructions(resource_params)

Have you tried this?

u.send_confirmation_instructions

EDIT to add Devise::Mailer-based method:

u.send(:generate_confirmation_token)
Devise::Mailer.confirmation_instructions(u, u.instance_variable_get(:@raw_confirmation_token))
like image 118
Buck Doyle Avatar answered Nov 15 '22 00:11

Buck Doyle