如何避免devise_invitable发送确认电子邮件?

问题描述 投票:2回答:3

从文档中,我认为不应发送确认电子邮件,但它正在这样做。

这是我为该邀请动作准备的设置:

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
ruby-on-rails devise devise-confirmable devise-invitable
3个回答
0
投票

[在某些情况下,您必须使用:confirmable进行用户注册,并且希望避免发送带有邀请的确认信-我必须修补DeviseInvitable#invite!方法:

DeviseInvitable#invite!

-1
投票

为了避免设计确认邮件,您必须从用户模型中排除class User < ApplicationRecord devise :invitable, :confirmable # devise_invitable invite! method overriden def invite! super self.skip_confirmation! self.save end end 选项。

例如,更改:

:confirmable

收件人:

 class User  
   devise :registerable, :confirmable
 end  

-3
投票

class User devise :registerable end 上的文档非常清楚如何跳过发送邀请电子邮件。查看用法下的第二个代码段,其后是该文本:

如果您要创建邀请但不发送邀请,则可以设置skip_invitation为true。

© www.soinside.com 2019 - 2024. All rights reserved.