重写设计after_sign_up_path_for不工作 [英] overriding devise after_sign_up_path_for not working
问题描述
在路由中,我有根路径指向home#index
,但是当我尝试使用after_sign_up_path_for覆盖它,当我登录时不断将我重定向到根路径或注册。我试图将它放在设计子类控制器和application_controller中,但它没有工作。我需要做什么?
In routes i have the root-path pointing "home#index"
but when i try to override that with after_sign_up_path_for keeps redirecting me to the root path when I sign in or sign up. I have tried to put it in both in devise subclassed controller and application_controller, but it didn't work. What do I need to do here?
应用程序控制器
class ApplicationController < ActionController::Base
protect_from_forgery
def after_sign_up_path_for(resource)
show_cities_path(resource)
end
end
注册控制器
class RegistrationsController < ApplicationController
def after_sign_up_path_for(resource)
show_cities_path(resource)
end
end
路线
root :to => "home#index"
推荐答案
您是否检查过您的show_cities_path ,通过执行 rake路线
?可能值得一看 https://github.com/plataformatec/devise/wiki/How-To:-Change-the-redirect-path-after-destroying-a-session-ie-signing-out
Have you checked your show_cities_path exists, by executing rake routes
? Might be worth having a look at https://github.com/plataformatec/devise/wiki/How-To:-Change-the-redirect-path-after-destroying-a-session-i.e.-signing-out
这篇关于重写设计after_sign_up_path_for不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!