2

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
wachichornia
  • 857
  • 9
  • 24

3 Answers3

1

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
Yurii Verbytskyi
  • 1,594
  • 3
  • 16
  • 22
  • `:skip_confirmation!` if you don't want any confirmation logic to be applied to this user. `:skip_confirmation_notification!` will disable letters but still force user to confirm email before allowing him to sign in – Marat Apr 20 '21 at 07:29
-1

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  
Len Jaffe
  • 3,414
  • 1
  • 19
  • 27
Tauqeer Ahmad
  • 460
  • 4
  • 9
-3

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.

Len Jaffe
  • 3,414
  • 1
  • 19
  • 27
  • 2
    I added an answer yesterday, I don't know where it is! I want it to skip the confirmation email, not the invitation one. I hacked into the invite! method and added self.skip_confirmation! – wachichornia Mar 20 '13 at 07:00