Ruby on rails 设计在接受邀请前要求确认
我正在rails应用程序中创建一个模块,用于向项目中“添加团队成员”。 我用的是Desive_ 在此,如果我添加一个新的电子邮件地址,确认邮件和邀请邮件都将被发送。。。因为这更有意义 我只想发送邀请邮件(在用户接受邀请邮件后,可以将其发送到注册页面)。。。在接受邀请之前确认是没有意义的 我目前的代码如下:Ruby on rails 设计在接受邀请前要求确认,ruby-on-rails,ruby,authentication,devise,Ruby On Rails,Ruby,Authentication,Devise,我正在rails应用程序中创建一个模块,用于向项目中“添加团队成员”。 我用的是Desive_ 在此,如果我添加一个新的电子邮件地址,确认邮件和邀请邮件都将被发送。。。因为这更有意义 我只想发送邀请邮件(在用户接受邀请邮件后,可以将其发送到注册页面)。。。在接受邀请之前确认是没有意义的 我目前的代码如下: def create_team_members # find the case @case = Case.find_by_id(params[:id])
def create_team_members
# find the case
@case = Case.find_by_id(params[:id])
# TODO:: Will change this when add new cse functionality is done
params[:invitation][:email].split(',').map(&:strip).each do |email|
# create an invitation
@invitation = Invitation.new(email: "#{email}".gsub(/\s+/, ''), role: params[:invitation][:role].rstrip, case_id: @case.id, user_type_id: params[:invitation][:user_type_id])
if @invitation.save
# For existing users fire the mail from user mailer
if User.find_by_email(email).present?
UserMailer.invite_member_instruction(@invitation).deliver
@invitation.update_attributes(invited_by: current_user.id)
else
# For new users use devise invitable
user = User.invite!(email: "#{email}", name: "#{email}".split('@').first.lstrip)
user.skip_confirmation!
user.save
@invitation.update_attributes(invitation_token: user.invitation_token, invited_by: current_user.id)
end
end
end
redirect_to dashboard_path
end
我不知道我做错了什么
请帮助…谢谢。有一个解决办法,我们可以超越用户模型中不可侵犯的设计。 目前,您的用户模型看起来像这样
class User < ActiveRecord::Base
devise :confirmable, :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :invitable
# Rest of the code
end
class用户
设备的发送确认指示的方法负责发送确认邮件。通过覆盖它我们可以停止发送确认电子邮件,同时让用户确认
换成这个
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :invitable
# Overriding devise send_confirmation_instructions
def send_confirmation_instructions
super
self.confirmation_token = nil # clear's the confirmation_token
self.confirmed_at = Time.now.utc # confirm's the user
self.save
end
# Rest of the code
end
class用户
现在邮件将不会被发送。有一个解决办法,我们可以超越用户模型中不可侵犯的设计。 目前,您的用户模型看起来像这样
class User < ActiveRecord::Base
devise :confirmable, :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :invitable
# Rest of the code
end
class用户
设备的发送确认指示的方法负责发送确认邮件。通过覆盖它我们可以停止发送确认电子邮件,同时让用户确认
换成这个
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :invitable
# Overriding devise send_confirmation_instructions
def send_confirmation_instructions
super
self.confirmation_token = nil # clear's the confirmation_token
self.confirmed_at = Time.now.utc # confirm's the user
self.save
end
# Rest of the code
end
class用户
现在邮件将不会被发送。仅通过查看代码,很难判断。params[:invitation][:email]参数是什么样子的?仅通过查看代码,很难判断。params[:invitation][:email]参数是什么样子的?