Routing error using form_tag
I have a routing issue which I can't seem to get my head around.
I have a project resource which has all the restfull actions working as expected.
Now I want to add the ability to update one specific attribute through a small popup form. So in this popup I use:
form_tag (@project) do
text_field_tag :attribute_i_want_to_update, ''
submit_tag 'go'
In the controller's update action I intend to handle this specific submit. However I receive a routing error claiming there is no route to '/projects/15'. I checked that the request is using a POST. Obviously a route exists for a POST to '/projects/15' (e.g. the regular update route works fine and po开发者_StackOverflowsts to that exact route).
What am I missing?
Thx for your time,
ErwinHave you tried specifying it as a PUT request:
form_tag(@project, :method => :put) do text_field_tag :attribute_i_want_to_update, '' submit_tag 'go'
I had similar problem, see it here
If the object is not new, then rails (at least 3 does this) will look for a PUT route, not POST. If you check what is really sent to the server, using Firebug for example, you will see that a POST is made but with a param "_method=put".
Rails will look for a PUT route to update an existing object, which is in accordance with Fielding's definition of REST.
精彩评论