[Form] Method POST & PUT problem

Hello,

I have a form that should be a POST method, but Rails insist to put a
hidden field “_method” that has the value “put” does anyone knows why?

Thanks,

David S.

Controller: -------------------------------
def new
@user = @current_user
end

View: -------------------------------------
<% semantic_form_for @user, :url => profile_reset_password_url do |form|
-%>
<% form.inputs -%>
<%= form.input :password -%>
<%= form.input :new_password -%>
<%= form.input :new_password_confirmation -%>
<% end -%>
<%= form.buttons %>

<% end -%>

Routes: -----------------------------------
map.namespace :profile do |profile|
profile.resource :reset_password, :only => [:new, :create]
end

Output: -----------------------------------

Informações
  1. Password*
  2. New password* New password confirmation*

On 17 Aug 2010, at 05:19, David S. wrote:

I have a form that should be a POST method, but Rails insist to put a
hidden field “_method” that has the value “put” does anyone knows why?

Since @user already exists in the database (you assign an existing
record @current_user to it) and is not a new_record?, Rails assumes
you want to update the record aka a PUT request. Probably just
adding :method => :post as a parameter will do the trick.

Thanks Peter, just adding :method => :post worked.

Let me ask one more thing, just after a submit the form, the firefox
open a dialog box asking me each of users that is in a list that I want
to change the password. Actually does not matter each you pick, the user
that you are logon on the site gets the pass changed.

Tks again.

David S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs