我正在尝试在注册后设计重定向到自定义页面。 它不起作用。 我有以下自定义注册控制器:
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 }
所以有趣的是注册控制器正在工作,因为第一个 put 语句显示在服务器日志中。 但是,第二个和第三个 put 语句(在after_sign_up_path_for和after_inactive_sign_up_path_for内)没有出现。
注册工作后如何获得重定向?
我建议你将这些帮助程序移动到ApplicationController(参见文档)并将它们放在公共命名空间中。