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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.