0

我有一个工人控制器。

如果我注销,我将被重定向到:localhost:3000. 我想被重定向到我设计的登录。

这是我的rake routes

users_sign_out           GET    /users/sign_out(.:format)       devise/sessions#destroy
new_user_session         GET    /users/sign_in(.:format)        devise/sessions#new
user_session             POST   /users/sign_in(.:format)        devise/sessions#create
destroy_user_session     DELETE /users/sign_out(.:format)       devise/sessions#destroy
user_password            POST   /users/password(.:format)       devise/passwords#create
new_user_password        GET    /users/password/new(.:format)   devise/passwords#new
edit_user_password       GET    /users/password/edit(.:format)  devise/passwords#edit
                         PUT    /users/password(.:format)       devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)         devise/registrations#cancel
user_registration        POST   /users(.:format)                devise/registrations#create
new_user_registration    GET    /users/sign_up(.:format)        devise/registrations#new
edit_user_registration   GET    /users/edit(.:format)           devise/registrations#edit
                         PUT    /users(.:format)                devise/registrations#update
                         DELETE /users(.:format)                devise/registrations#destroy

这是我的routes.rb

devise_for :users do get '/users/sign_out' => 'devise/sessions#destroy' end
resources :tasksadmins
resources :workers
root to: "devise/registrations#create"
4

2 回答 2

1

它在设计 wiki 中指定。

https://github.com/plataformatec/devise/wiki/How-To:-Change-the-redirect-path-after-destroying-a-session-ie-signing-out

class ApplicationController < ActionController::Base
  private

  # Overwriting the sign_out redirect path method
  def after_sign_out_path_for(resource_or_scope)
    new_user_session_path
  end
end
于 2013-01-02T00:11:50.350 回答
1

您可以在应用程序控制器中覆盖after_sign_out_path_for助手。

def after_sign_out_path_for(resource_or_scope)
  # logic here
end
于 2013-01-02T00:12:56.033 回答