Reputation: 1412
I have included confirmation module in devise gem and it working fine but i need to alert the user with some flash message on after 2 days(based on the devise config) for unconfirmed emails on login.
config.allow_unconfirmed_access_for = 2.days
how to add a button to resend mail for confirmation.
Upvotes: 0
Views: 2535
Reputation: 41884
You need to create a button which links to a controller action, and create a route for it like resend_email_path(user)
. Inside the controller action you need to include:
def resend_email
user = User.find(params[:id])
user.send_confirmation_instructions
end
For more information on this method see:
Once you get it working normally you could do it ajaxy with remote: true
To add the flash message, put this in in the controller action where your uncomfirmed user is:
if current_user.confirmation_period_expired?
flash[:error] = "Confirmation Time Expired. #{link_to 'Resend email', resend_email_path(user)}".html_safe
end
Upvotes: 1