Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PUT method form_for

I am using the following to try and set a PUT method on the form but it is still doing a post. I have referred to the docs and it seems like im doing this right.

form_for @firm, html: {autocomplete: "off"}, url: firm_path, method: :put do |f|
...
like image 973
Jason Waldrip Avatar asked Mar 04 '12 00:03

Jason Waldrip


1 Answers

It does this because browsers don't support PUT/DELETE very well. You can read more about this in the Rails Guides:

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.

like image 85
Andrew Marshall Avatar answered Oct 07 '22 15:10

Andrew Marshall