How to make PUT with html forms?


I’m trying to emulate a post from a HTML form. I’ve the following code in erb:

Alterar Password

<% form_tag :action=>“reset_password”, :method=>“put” do%>

<%=label_tag :password, “Nova password” %>

<%=password_field_tag :password, @password %>

<%=label_tag :password_confirmation, “Confirmação Password” %>

<%=password_field_tag :password_confirmation, @password_confirmation %>

<%=submit_tag “Alterar Password” %>

<%end %>

In my action I have something similar to this:

def reset_password

if request.get?

#do something for get

elsif request.put?

#do something for put


raise Webapp::BadRequestError


rescue Webapp::BadRequestError

logger.error("Invalid Request type. Client IP: "+request.remote_ip)


redirect_to root_url


I’ve functional tests for put and get, and everything is fine. But when the form is rendered and tested in a browser I can’t get this working. In Firefox, the output for the erb is something like:

Nova password

Confirmação Password

Everytime I submit the form I then hit in the Webapp::BadRequestError

Can someone help me get over this?

I made some researche and found in Ruby on Rais guides that I’m doing the correct thing… but I’m not getting the correct results. I know I’m missing something… what is?

Can you help?

Try ':method => :put' (without the quotes). Rails is not always consistent.
Some places either strings or symbols work, other places they don't.


Quoting Jonhy Pear <>:

there is a bug in 2.3.4 that breaks PUTs in Ajax calls, this could be your issue

Thank you. I tried just that now. But still produce the same result:

And no hidden field named _method, as stated in documentation.

Ok, thank you. My form is not AJAXified. I managed to fix the problem. It probably has something to do with the rendering of the form using form_tag.

If I have hardcoded the hidden field, everything is fine:

<%=password_field_tag :password_confirmation, @password_confirmation %>

This is a hack and I would like to know if you now something about this.

Why don’t you create a controller for ‘reset_password’, using RESTfull methods. Use ‘new’ action for the GET and ‘update’ for PUT.