Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

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 %>
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした