如果未经身份验证的用户尝试访问users/edit
,请设计将其重定向到users/sign_in
。这很好。但是,成功登录后,我希望将用户重定向回users/edit
。这怎么可能。
答案 0 :(得分:1)
您是否覆盖了after_sign_in_path_for
方法?查看有关How To: redirect to a specific page on successful sign in
无论如何,AFAIK,如果您没有覆盖此方法,则默认行为是将用户重定向到last stored location,'用户/编辑'。在用户登录之前,请查看应用程序中stored_location_for
的内容。
答案 1 :(得分:1)
我将问题解释为how do I redirect back after sign in
,答案就是:
class ApplicationController < ActionController::Base
def after_sign_in_path_for(resource)
request.env['omniauth.origin'] || stored_location_for(resource) || root_path
end
end
答案 2 :(得分:0)
参考此链接,它解释了您正在寻找的方案 devise help
希望有所帮助:)