42
35

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【解決策】deviseのログアウト機能でのエラー

Posted at

Railsアプリでdeviseを使用し、ログアウトをしようとすると以下のエラーが出た。

No route matches [GET] "/users/sign_out"

###原因・解決策
routesが合っていないのが原因なので、書き換えないといけない。
以下のコードを追加する。このコードは既存のログアウトルーティングに上書きされる。

routes.rb
  devise_scope :user do
    get '/users/sign_out' => 'devise/sessions#destroy'
  end

ちなみにviewは以下のままで大丈夫。

<%= link_to "ログアウト", destroy_user_session_path, method: :delete %>
42
35
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
42
35

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?