form_tag error: only get requests allowed

I am getting above error while updating an item using form_tag helper.

<h1>Edit Topic Item</h1>

<% form_tag edit_topic_item_path(@item.topic, @item), :html => { :method => :put} do %>   <%= render :partial => 'item_form', :object => @item %>   <%= submit_tag 'Save' %> <% end %>

<%= link_to 'Add Sub-Item to this Element', :action => :add_subitem, :id => @item %> <br /> <br />

Any clues?

I am getting above error while updating an item using form_tag helper.

<h1>Edit Topic Item</h1>

<% form_tag edit_topic_item_path(@item.topic, @item), :html =>
{ :method => :put} do %> <%= render :partial => 'item_form', :object => @item %> <%= submit_tag 'Save' %> <% end %>

<%= link_to 'Add Sub-Item to this Element', :action
=> :add_subitem, :id => @item %> <br /> <br />

edit_topic_item_path returns the path to the edit page, which isn't
where you want to send your updates to

If I were you I'd just use form_for which hangles all that sort of
stuff for you.

Fred

Thanks Fred once again A big blunder over there.. :frowning:

I am cleaning up someone else's code and I am new to to rails. And majority of the developers seem to be using form_for and not form_tag. I found it useful as it directly handles ActiveRecord objects... So for my new code I am using the same.

Frederick Cheung wrote: