被重定向到users / sign_in

时间:2013-01-01 23:56:33

标签: ruby-on-rails redirect

我有一名工人控制员。

如果我退出,我会被重定向到:localhost:3000。我想重定向到我的设计的sign_in。

这是我的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"

2 个答案:

答案 0 :(得分:1)

在设计维基中指定。

https://github.com/plataformatec/devise/wiki/How-To:-Change-the-redirect-path-after-destroying-a-session-i.e.-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

答案 1 :(得分:1)

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

def after_sign_out_path_for(resource_or_scope)
  # logic here
end
相关问题