after_sign_up_path_for不工作 - 设计

时间:2014-02-10 18:14:44

标签: ruby-on-rails model-view-controller devise ruby-on-rails-4 rails-routing

我正在尝试在注册后设计重定向到自定义页面。它不起作用。我有以下自定义注册控制器:

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中)没有出现。

如何在注册上班后获得重定向?

1 个答案:

答案 0 :(得分:0)

我建议您将这些帮助程序移动到ApplicationController(请参阅docs)并将它们放在公共名称空间中。