I'm using devise confirmable. I want to give the user a link to click and resend the confirmation email. Problem is, when the user clicks the link, it isn't going to the devise controller. Is there something I'm missing in the routes.rb file? Here is my setup:
routes.rb
devise_for :users, :controllers => { :registrations => "registrations", :sessions => "sessions", :omniauth_callbacks => "authentications" }
user.rb
devise :omniauthable, :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable
The view:
<a href="/users/confirmation/new" data-remote="true" data-method="post">Resend confirmation</a>
Thanks
to send confirmation instructions to the user you find the user and then just user.send_confirmation_instructions
namespace :user do
task :resend_confirmation => :environment do
users = User.where('confirmation_token IS NOT NULL')
users.each do |user|
user.send_confirmation_instructions
end
end
end
resource_params
is a method defined at devise controller which gets the controller resources specific do device resource (User) for example. definition in DeviseController
def resource_params
params.fetch(resource_name, {})
end
so in order to pass the email as a parameter you neet to include it in a user hash, so in the view instead of
link_to('resend', user_confirmation_path(email: "[email protected]"), :method => :post)
insert the email in a Hash
link_to('resend', user_confirmation_path(user: {:email => "[email protected]"}), :method => :post)
this way devise will pick up the email parameter
Pretty old post. Though, instead of sending the instructions directly, you might just want to point the user to Devise's workflow:
= link_to 'Resend confirmation', new_user_confirmation_path
That'll take the user to Devise's view requesting the email to send the confirmation instructions.
Hope it helps anyone, anyway. :)
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