【问题标题】:When does Devise store the location for stored_location_for_resourceDevise什么时候存储stored_location_for_resource的位置
【发布时间】:2012-10-26 23:24:15
【问题描述】:

当该页面需要登录Devise Resetting Session On Login 时,我在重定向到上次访问的页面时遇到问题,有人指出您可以按照此处的代码示例进行操作:https://github.com/plataformatec/devise/wiki/How-To%3A-redirect-to-a-specific-page-on-successful-sign-in

那个例子调用stored_location_for(resource)...那个集合在哪里?

当在我的适当控制器中与before_filter :authenticate_user! 结合使用时,该示例可以完美运行。查看authenticate_#{resource}!https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/helpers.rb的源代码,似乎没有保存位置。

以前的位置存储在世界的什么地方?

【问题讨论】:

    标签: ruby-on-rails authentication redirect devise


    【解决方案1】:

    路径存储在session["user_return_to"] 中(假设user 是您的型号名称)。

    这似乎是由store_location!failure_app.rb 中设置的

    请注意,如果您只有一个设计模型,则登录重定向应该会自动工作,您无需在 application_controller.rb 中覆盖 after_sign_in_path_for

    【讨论】:

    • 注意到默认的sign_in_path 可能会起作用,感谢您确认。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-19
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 2011-06-23
    • 1970-01-01
    • 2023-04-09
    相关资源
    最近更新 更多