1
0

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.

rails エラー例 Rooting error

Last updated at Posted at 2018-03-24

Rooting error
● rootパスが間違っている

root to: "tweet#index"  本来はtweets

●該当するルーティングが設定されていない。

tweetsのshowのルーティングがなく、shoeというルーティングが設定されている。

#before
resources :tweets, only: [:index, :shoe, :new, :create, :destroy, :edit, :update]
#after
resources :tweets, only: [:index, :show, :new, :create, :destroy, :edit, :update]

●該当するルーティング無いことが原因。

resources :tweets, only: [:index, :show, :new, :create, :destroy, :edit, :update] 
resources :comments, only: [:create]
#after

resources :tweets, only: [:index, :show, :new, :create, :destroy, :edit, :update] do
resources :comments, only: [:create]
end


コメントのルーティングをツイートのルーティングにネストしていないため、form_tagで設定したようなルーティングが設定されていなかった。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?