首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ruby : confirmations_controller stop registrations_controller

Ruby : confirmations_controller stop registrations_controller
EN

Stack Overflow用户
提问于 2022-10-11 13:18:19
回答 1查看 23关注 0票数 0

我对设计有问题,我找不到解决办法。

当用户sign_up时,我需要调用几个服务来创建他的配置文件。这里是registrations_controller.rb

代码语言:javascript
复制
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”方法。

你知道发生了什么事吗?

EN

回答 1

Stack Overflow用户

发布于 2022-10-11 16:05:27

我想说它是从这条线上传来的

controller.rb#L28

由于您无法登录而没有确认您的电子邮件,我很确定create_astroprofilcreate_affinities是打电话,但他们的第一行是return unless user_signed_in?

这里有2种选择:

  • 对于未确认的用户,可以调用Astroprofil.newAffinities.new
  • 名为create_astroprofilcreate_affinitiesConfirmationController#show
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74028807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档