ruby-on-railsdevisedevise-confirmableemail-confirmation

Ruby on Rails - Devise - Send sign up confirmation email on action other than usual sign up


Using Devise, how can I send confirmation email (identical to signup email) on first password update (or on an action other than usual sign up)?


Solution

  • I did it by adding a condition to create method in confirmations_controller.rb

    def create
      self.resource = resource_class.send_confirmation_instructions(resource_params)
      yield resource if block_given?
    
      if successfully_sent?(resource)
        respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
      else
        if <condition> then
         User.find_by_email(resource.email).send_confirmation_instructions
         respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
        else
          respond_with(resource)
        end
      end
    end