This project is archived and is in readonly mode.
Route not resolving properly
Reported by mudboy | August 27th, 2008 @ 08:52 PM | in 2.x
While doing some integration testing on a mapped resource. I found that the route for the update action was not resolving.
If I called post with '/admin/books/239493' then the routing code would return params of {:action => '239493', :controller => 'admin/books'}
Somehow the id was being assigned to the action.
Comments and changes to this ticket
-
mudboy September 1st, 2008 @ 09:57 AM
It's very easy to repeat this bug, and it only seems to effect the integration test.
step to reproduce.
$ rails appname
then
$ script/generate scaffold Book title:string description:text
run the migration
$ rake db:migrate
make a integration test
$ script/generate integration_test Book
Then add the following to the test.
def test_truth id = books(:one).id post "/books/#{id}", :book => { :title => 'hello'} assert_response :success @@@@
-
Mike Weber September 3rd, 2008 @ 05:30 AM
I don't believe this is a bug in Rails. The routing code is resolving to the only route that makes sense for a POST. But in a RESTful application, POSTs are only used for creating resources, which don't have an ID in the route. You'll need to use PUT in your test, rather than a POST.
-
mudboy September 3rd, 2008 @ 10:50 AM
Thanks for your insight Mike, I have been tearing my hair out trying to work out why this wasn't working. It just stems from my not understanding how the RESTful routes work.
For future reference where is the best place to ask questions like this?
-
Michael Koziarski September 3rd, 2008 @ 12:56 PM
elsif ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager] == CGI::Session::CookieStore && session.respond_to?(:dbman) && session.dbman.respond_to?(:generate_digest)
Couldn't you just do:
if ActionController::Base.session_store == CGI::Session::CookieStore
Or is there a case where we're using the cookie store and don't have dbman respond_to
-
Mike Weber September 3rd, 2008 @ 04:43 PM
The best resources for help with understanding Rails would either be the mailing list http://lists.rubyonrails.org/mai... or the #rubyonrails IRC channel on irc.freenode.net.
-
Tarmo Tänav September 18th, 2008 @ 04:30 AM
- State changed from new to invalid
- Tag changed from 2.1, actionpack, bug, routing to 2.1, actionpack, bug, routing
Looks like Michael actually intended to reply to #957 :), closing this due to not being a bug.
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>