覆盖设计 after_sign_up_path_for 不工作 [英] overriding devise after_sign_up_path_for not working

查看:16
本文介绍了覆盖设计 after_sign_up_path_for 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在路由中,我有指向 "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"

推荐答案

您是否通过执行 rake routes 检查您的 show_cities_path 是否存在?可能值得一看 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆