This project is archived and is in readonly mode.

#3823 ✓invalid
Raf

form_for targeting wrong url

Reported by Raf | January 31st, 2010 @ 09:07 AM

I SOLVED THIS PROBLEM WITH :URL => RESOURCE_PATH(@RESOURCE), BUT I DON'T KNOW HOW TO CLOSE THE TICKET. PLEASE CLOSE THIS, IF YOU COME ACROSS IT.

Wondering if anyone can help, or is having the same problem. I have a form_for helper nested inside an index view, because index viewers need to be able to update a parameter without going to a separate page (like the edit route). But this form is sending a put request to the non-specific route (/resources) instead of the specific route indicated in the generated html (/resources/:id). Put requests should be directed to the specific route to call the update action, so I'm getting an error and the database does not update.

(controller is default scaffolded version)

(index.html.erb)

<td><% form_for :resource do |f|%>
<%= f.text_field :parameter %>
<%= f.submit 'Update' %>
<% end %></td>

(routes.rb) map.resources :resources

(generated html)


<input id="resource_parameter" name="resource[parameter]" size="30" type="text" value="wtf" />
<input id="resource_submit" name="commit" type="submit" value="Update" /> 
</form></td>

(development log) Processing ApplicationController#index (for 127.0.0.1 at 2010-01-31 03:33:08) [PUT]
Parameters: {"commit"=>"Update", "resource"=>{"parameter"=>"wtf"}, "authenticity_token"=>"OhvJjk4SyiyEKdNo6/Toqhqnsi6IWolgDlsihHT1iR4=", "pairedtable_length"=>"10"}

ActionController::MethodNotAllowed (Only get and post requests are allowed.)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages