从文档中,我认为不应发送确认电子邮件,但它正在这样做。
这是我为该邀请动作准备的设置:
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
[在某些情况下,您必须使用:confirmable
进行用户注册,并且希望避免发送带有邀请的确认信-我必须修补DeviseInvitable#invite!
方法:
DeviseInvitable#invite!
为了避免设计确认邮件,您必须从用户模型中排除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
class User
devise :registerable
end
上的文档非常清楚如何跳过发送邀请电子邮件。查看用法下的第二个代码段,其后是该文本:
如果您要创建邀请但不发送邀请,则可以设置skip_invitation为true。