Rails 4 not changing post method to patch

前端 未结 4 872
萌比男神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:26

    Just to answer your question from title, I think your form method is "PATCH" indeed. Refer to the guide http://guides.rubyonrails.org/form_helpers.html about how rails makes a patch form.

    The Rails framework encourages RESTful design of your applications, which means you'll be making a lot of "PATCH" and "DELETE" requests (besides "GET" and "POST"). However, most browsers don't support methods other than "GET" and "POST" when it comes to submitting forms.

    Rails works around this issue by emulating other methods over POST with a hidden input named "_method", which is set to reflect the desired method:

提交回复
热议问题