我对设计有问题,我找不到解决办法。
当用户sign_up时,我需要调用几个服务来创建他的配置文件。这里是registrations_controller.rb。
require_relative '../../../app/services/affinities'
require_relative '../../../app/services/astroprofil'
require_relative '../../../app/services/geocode'
class Users::RegistrationsController < Devise::RegistrationsController
ASTROPROFIL = Astroprofil.new
AFFINITIES = Affinities.new
GEOCODE = Geocode.new
after_action :create_astroprofil, only: %i[new create]
after_action :create_affinities, only: %i[new create]
private
def create_astroprofil
return unless user_signed_in?
ASTROPROFIL.profil(current_user)
end
def create_affinities
return unless user_signed_in?
affinities(current_user, ten_mates)
end
def affinities(user, mates)
AFFINITIES.partner_report(user, mates)
AFFINITIES.sign_report(user, mates)
AFFINITIES.match_percentage(user, mates)
end
def ten_mates
mates_by_gender = User.where(gender: current_user.looking_for).where.not(id: current_user.id)
return mates_by_gender.sample(10)
end
end当我注册所有的工作完美,一个新的用户完全创建。
但是,一旦我尝试用devise添加每封邮件的确认信息,邮件就会被发送,但它会停止“create_astroprofil”和“create_affinities”方法。
你知道发生了什么事吗?
发布于 2022-10-11 16:05:27
我想说它是从这条线上传来的
由于您无法登录而没有确认您的电子邮件,我很确定create_astroprofil和create_affinities是打电话,但他们的第一行是return unless user_signed_in?。
这里有2种选择:
Astroprofil.new和Affinities.newcreate_astroprofil和create_affinities的ConfirmationController#showhttps://stackoverflow.com/questions/74028807
复制相似问题