Sunday, October 25, 2009

Specify form method when generating url route for edit form

Scratch head moment when I didn't specify ":method => :put" for edit form coz the form keeps leading me to "create" action.

<% form_for @class_test, :url => class_test_path(@class_test) do |f| -%>
<%= render :partial => f %>
<%= f.submit "Save" %>
<% end -%>

This was resolved after specifying the "put" method.

<% form_for @class_test, :url => class_test_path(@class_test), :html => {:method => :put} do |f| -%>
<%= render :partial => f %>
<%= f.submit "Save" %>
<% end -%>

No comments:

Blog Archive