LoginSignup
0
2

More than 3 years have passed since last update.

CarrierWave で No route matches [PATCH]  のエラー

Last updated at Posted at 2018-06-25

ルーティングが上手くいってないのは、分かるがどう解決したらよいかわからないレベルの人のため。
CarrierWave で画像を投稿ボタンを押した際に、No route matches [PATCH]*******というエラーがでる。

「 No route matches CarrierWave 」あたりで検索しても、自分の場合はマッチする解答が出て来ませんでした。 

解決方法は、

config/routes.rb のファイルの以下の部分

resources :users, only: [:show, :index, :destroy]

に:update を加えて以下のように記述すればよいです。

resources :users, only: [:show, :index, :update, :destroy]

つまり、投稿ボタンを押した際、モデルのコントローラーのupdateアクションが実行されているので、
ルーティングでupdateを許可しないと、通らないというわけである。

なぜ、updateアクションが実行されるのが分かったかというと、自分の場合は、手当たりしだいにブレークポイントを挿入してupdateアクションが実行されていることを発見しました。

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