Resend confirmation email devise

In Devise, you can resend a confirmation email to a user by calling the resend_confirmation_instructions method on the user object. Here's an example:

user = User.find(params[:id])
user.resend_confirmation_instructions

This will send a new confirmation email to the user with a new confirmation link.

If you want to customize the email that is sent, you can override the confirmation_instructions method in your User model:

class User < ApplicationRecord
  #...

  def confirmation_instructions
    # Custom email content here
    Devise::Mailer.confirmation_instructions(self, @token).deliver_now
  end
end

You can also use the resend_confirmation_instructions method in a controller action, for example:

def resend_confirmation
  user = User.find(params[:id])
  user.resend_confirmation_instructions
  redirect_to root_path, notice: "Confirmation email resent successfully"
end

Make sure to add a route for the resend_confirmation action in your routes file:

get '/resend_confirmation/:id', to: 'users#resend_confirmation'

Also, you can use resend_confirmation_instructions method in a mailer, for example:

class UserMailer < ApplicationMailer
  def confirmation_instructions
    @user = params[:user]
    @token = params[:token]
    mail to: @user.email, subject: "Confirm your email"
  end
end

And then call the method in your controller:

def resend_confirmation
  user = User.find(params[:id])
  UserMailer.confirmation_instructions(user).deliver_now
  redirect_to root_path, notice: "Confirmation email resent successfully"
end

Please note that you need to have Devise's confirmable module enabled in your User model for this to work.