【发布时间】:2026-01-19 00:40:01
【问题描述】:
我正在尝试在注册后设计重定向到自定义页面。它不工作。我有以下自定义注册控制器:
class RegistrationsController < Devise::RegistrationsController
protected
puts 'Registrations controller is happening"
def after_sign_up_path_for(resource)
puts 'after_sign_up_path_for is working'
"http://www.google.com"
end
def after_inactive_sign_up_path_for(resource)
puts 'after_inactive_sign_up_path_for is working'
"http://www.google.com"
end
end
这是我的自定义路线:
devise_for :users, :controllers => { :registrations => :registrations }
所以有趣的是注册控制器正在工作,因为第一个 puts 语句显示在服务器日志中。但是,第二个和第三个 put 语句(在 after_sign_up_path_for 和 after_inactive_sign_up_path_for 内)没有出现。
注册工作后如何获得重定向?
【问题讨论】:
-
不是重复的。我看到了这个问题,但答案对我不起作用。
-
你检查其他答案了吗?
-
是的,我已经查看了所有堆栈溢出页面和其他我能找到的资源。
-
您是否有机会更改设计路线的默认名称?你在
routes.rb文件中使用devise_scope吗? -
不,我在上面发布的路线文件中关于设计的唯一更改。
标签: ruby-on-rails model-view-controller devise ruby-on-rails-4 rails-routing