Question

from the docs i think it should to not send a confirmation email, but it is doing it.

Here's my setup for the invitable action:

class Users::InvitationsController < Devise::InvitationsController

def multiple_create
    if params[:multiple_emails].blank?
        build_resource
        render :new, notice: "something went wrong"
    else
        params[:multiple_emails].each do |email|
            User.invite!({email: email}, current_user) # current_user will be set as invited_by
        end
        if current_user.errors.empty?
            set_flash_message :notice, :send_instructions, :email => params[:multiple_emails]
            respond_with current_user, :location => after_invite_path_for(current_user)
        else
            respond_with_navigational(current_user) { render :new }
        end
    end
end
end
Was it helpful?

Solution

For the cases, where you have to use :confirmable for user registration and want to avoid sending confirmation letters with invitation:

class User < ApplicationRecord
  after_create :skip_confirmation_notification!, unless: Proc.new { self.invitation_token.nil? }
end

OTHER TIPS

To avoid devise confirmation mail, you have to exclude :confirmable option from the User model.

For example, change:

 class User  
   devise :registerable, :confirmable
 end  

To:

 class User  
   devise :registerable
 end  

The documentation at devise_invitable repo on github are very clear on how to skip sending the invitation email. Look at the second code snippet under Usage, which is preceded by this text:

If you want to create the invitation but not send it, you can set skip_invitation to true.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top