【问题标题】:Change devise default root更改设计默认根
【发布时间】:2012-08-15 12:54:45
【问题描述】:

我的根页面是一个欢迎页面,其中包含一个打开注册模式的链接。

我有需要验证的特定页面。当我转到那个特定页面时,我被重定向到 localhost:3000/users/sign_in。但我想将用户重定向到我的主页并显示模式。我的意思是我希望登录页面是 localhost:3000/ 并且以某种方式,只是在这种情况下传递一个参数,让我知道我必须打开弹出窗口。

我的意思是, 当我转到 localhost:3000 时,我应该只显示主屏幕。

但是如果我去 localhost:3000/myspecificpagewithauthentication 我应该被重定向到 localhost:3000?showsignup=true (为了能够使用 JS 显示模式)并且在注册后我应该再次被重定向到 localhost: 3000/myspecificpagewithauthentication(已通过身份验证)。

我正在使用 Devise 和 RoR 3。

有什么帮助吗?谢谢。

【问题讨论】:

    标签: ruby-on-rails-3 devise


    【解决方案1】:

    devise 是一个有据可查的 gem。 here你去

    更新:

    要更改登录后路径,请将您自己的 after_sign_in_path_for 方法写入应用程序控制器。这将覆盖设计的方法。

    class ApplicationController < ActionController::Base
    
    def after_sign_in_path_for(resource)
      your_custom_path
    end
    
    end
    

    【讨论】:

    • 这非常有用。谢谢。现在我可以重定向到我的根目录,但我需要知道我是来自 localhost:3000/myspecificpagewithauthentication 还是 localhost:3000。这可能吗?
    • 我需要做的是在身份验证后将用户重定向到 localhost:3000/myspecificpagewithauthentication。我该怎么做?
    猜你喜欢
    • 2012-06-20
    • 2014-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 2020-01-08
    • 2013-08-07
    相关资源
    最近更新 更多