LoginSignup
2
1

More than 5 years have passed since last update.

deviseのサインイン・サインアップで別のviewにとんでしまう

Last updated at Posted at 2018-05-31

ルーティングを記述する順番が大事

deviseを実装し問題なく動作することを確認。
その後、deviseにないUserのindexとshowアクションを追加して再度サインイン・サインアップしようとすると、何故かuserのshowページに飛んでしまう。

viewは触っていないし特にエラーは出ていないのでルーティングを見直したところ、userのルーティングをdeviseの下にもっていったらちゃんとしたページに飛ぶようになりました!

Before
routes.rb
Rails.application.routes.draw do
  root to: "articles#index"
  resources :articles
  resources :users, only: [:index, :show]
  devise_for :users
end
After
routes.rb
Rails.application.routes.draw do
  root to: "articles#index"
  devise_for :users
  resources :articles
  resources :users, only: [:index, :show]
end
2
1
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
2
1