Rails 4 not changing post method to patch

前端 未结 4 905
萌比男神i
萌比男神i 2021-01-14 08:34

I am trying to submit a form, but if I just put form_for @classroom I get a \"No route matches [POST]\" error.

Now with the code posted below, I get th

4条回答
  •  死守一世寂寞
    2021-01-14 09:06

    form_for takes an object as first argument, and its usually better to keep the REST-like way of rails handling the update method.

    The action of you html form displays "/classrooms/23/edit" so yes it won't work.

    form_for(@classroom, url: update_classroom_path(@classroom), method: "patch")
    

提交回复
热议问题