LoginSignup
17
16

More than 5 years have passed since last update.

No route matches [POST] のエラー 解決法

Posted at

エラーの概要

No route matches [POST] のエラー 解決法

screenshot.png

chat_roomsモデルでshow.html.erbでエラーが起きている

rake routesをすると以下で出てくる。


 chat_rooms GET    /chat_rooms(.:format)          chat_rooms#index
                         POST   /chat_rooms(.:format)          chat_rooms#create
           new_chat_room GET    /chat_rooms/new(.:format)      chat_rooms#new
               chat_room GET    /chat_rooms/:id(.:format)      chat_rooms#show
                    root GET    /                              chat_rooms#index



 自分の失敗した点

自分は、 chat_room GET /chat_rooms/:id(.:format) chat_rooms#showがあるから、いまいちわからない。

get とpostは、違う点に気づいた。4つのHTTPメソッドの「GET」「POST」「DELETE」「PUT」を使うこと

詳しい説明のリンク
http://www.rubylife.jp/rails/routing/index5.html

エラーの解決

postのルートを作る。

routes.rb
post 'chat_rooms/:id' => 'chat_rooms#show'

作った解決する

17
16
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
17
16