I am experimenting with a combined form. I wish to force the HTTP verb for this form to PUT. However, it always uses POST when submitted and I cannot determine why.
The view template code is:
<%=form_for( @user, :html => { :class => :edit_user_role, :id => :edit_user_role_form, :method => :put }, :url => user_roles_url( @user )
) do |f|-%>
The resulting html is:
<form accept-charset="UTF-8" action="http://www.example.com/users/330/roles" class="edit_user_role" id="edit_user_role_form" method="post"> <div style="margin:0;padding:0;display:inline"> <input name="utf8" type="hidden" value="✓" /> <input name="_method" type="hidden" value="put" /> </div>
This confuses me. The form method is not being set by the html attribute but a hidden field is being created instead. Since Rails considers only the HTTP verb for routing this simply will not work as I expect.
What is the problem with my approach? How does one set the form method?