[英]redirecting after sign out with devise
我正在使用devise 4.0.0和rails 4.2.6。 我試圖讓設計人員重定向到用戶進入設計登錄頁面之前或單擊注銷之前的頁面(這是指向destroy_user_session_path的鏈接)。 我已經閱讀了設計方法如何https://github.com/plataformatec/devise/wiki/How-To:-Redirect-back-to-current-page-after-sign-in、-sign-out、-sign-向上,更新說它已經過時了,我應該閱讀我做過的代碼https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/store_location.rb ,但是沒有。不能幫助我弄清楚我需要做什么。 我搜索了一堆SO Q / As,其中許多也過時了。 其中一位為我工作,負責登錄。 我補充說:
before_filter :store_current_location, :unless => :devise_controller?
private
def store_current_location
store_location_for(:user, request.url)
end
到我的ApplicationController。 但是注銷仍然恢復到根源。 我覆蓋了after_sign_out_path_for(resource),發現stored_location_for(resource)為零。 我不知道為什么。 建議的其他SO Q / A:
private
def after_sign_out_path_for(resource)
stored_location_for(resource) || request.referrer || root_path
end
這似乎可以通過request.referrer部分來解決問題。 我不知道要刪除存儲的位置。 在我上面鏈接的設計代碼中,存儲的位置僅在我們檢索到它時才被刪除,而這似乎沒有發生。
我是Rails的新手,所以我可能缺少一些非常明顯的東西。 誰能向我解釋為什么stored_location_for(資源)為零? 還是在哪里刪除?
嘗試
request.referrer
為了獲得以前的網址
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.