0
當用戶登錄時,它們會自動路由到/ user頁面。 如何在登錄後將它們定向到主頁(home.htm.erb)?如何在登錄後重定向用戶? (Ruby on Rails)
當用戶登錄時,它們會自動路由到/ user頁面。 如何在登錄後將它們定向到主頁(home.htm.erb)?如何在登錄後重定向用戶? (Ruby on Rails)
我假設你有一個Sessions對象,你正在創建?在sessions#create
行動
redirect_to root_url
根據您的寶石認證
在你的app/controllers/application_controller.rb
class ApplicationController 'new', :controller => 'sessions', :only_path => false, :protocol => 'http') if request.referer == sign_in_url super else stored_location_for(resource) || request.referer || root_path end end end
看到http://stackoverflow.com/questions/8640326/redirect -user-after-log-in-only-if-its-on-root-path – jazzytomato 2013-03-03 00:31:21
這實際上取決於你的代碼。你是否使用某種形式的驗證寶石像devise或omniauth?還是你推出自己的?你需要在你的問題中包含這些細節。 – jvnill 2013-03-03 03:11:15