gpt4 book ai didi

ruby-on-rails - 设计 after_sign_up_path_for 不被调用

转载 作者:行者123 更新时间:2023-12-03 15:36:12 27 4
gpt4 key购买 nike

我正在使用带有多个模型的 Devise 进行身份验证、管理员和用户。在用户注册时,我想重定向到个人资料页面。 (管理员是使用 rake 任务或通过 admin Admin 页面创建的,而不是通过注册过程。)

我正在使用 Ruby 2.0.0、Rails 4 和 Devise 3.1.0。

这是我用来进行重定向的代码,根据 StackOverflow 和 Devise GitHub 页面上的帮助。

class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!

def after_sign_up_path_for(resource)
Rails.logger.info('ApplicationController: after_sign_up_path_for called')
'/profile'
end

def after_inactive_sign_up_path_for(resource)
Rails.logger.info('ApplicationController: after_inactive_sign_up_path_for called')
'/profile'
end
end

但是,当我运行注册时,似乎没有调用 after_sign_up 或 after_inactive_sign_up 方法,因为没有出现日志记录。

现在我已经四处寻找,我似乎找不到我的代码有什么问题。我想知道这是否是由于我使用的多模型模型。

有人能解释一下吗?

如果您需要查看更多代码或其他信息,请询问。

最佳答案

关于ruby-on-rails - 设计 after_sign_up_path_for 不被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21571569/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com