Rails "path_prefix" produces no correct verb route evaluation

Hi guys! :wink:

If you set “routes.rb” as:

map.resources :pocoyo

You have RESTful rails routes facilites. Ok, let’s focus on these two
maps:

http://domain.com/pocoyo” [GET] is mapped to “pocoyo” controller
and “index” action.
http://domain.com/pocoyo” [POST] is mapped to “pocoyo” controller
and “create” action.

if you adds “:path_prefix” as:
map.resources :pocoyo, :path_prefix=‘:country’

You have the same RESTful rails routes faicilites, but with non
correct behavior on POST calls:

http://domain.com/pocoyo” [GET] is mapped to “pocoyo” controller
and “index” action.
http://domain.com/pocoyo” [POST] is mapped to “pocoyo” controller
and “INDEX” action. (incorrectly to “index” instead to the correct
“create” action)

if you review your “rake routes” results, you can see that “http://
domain.com/pocoyo” called with POST verb is mapped to “create” action
and not for “index” action that is matching with “GET” verb.

If you debug the http call, you can see that a correct POST is
processing.

I came to conclusion that, using “path_prefix” on you routes rules,
produces no corrects maps for verb evaluation.

Only if provides url with “:country”, like “http://domain.com/
somecountry/pocoyo” [POST] can be correctly mapped to “create” action.

If rails route can map “http://domain.com/pocoyo” [GET]" with a
“path_prefix” to correct action, should be able to map correctly
http://domain.com/pocoyo” [POST]" to their appropriate action, giving
the verb as the normal RESTful mapping way.

Some reasoning about ???
Thanks!

I can confirm this. Rails 2.3.6.

Interestingly, it tries to run both create AND index. For example, in
my app, it posts to the correct create action in the controller;
however, I have global error rescuing via:

rescue_from Exception, :with => :rescue_all_exceptions if RAILS_ENV ==
‘production’

That block is catching the following:

No action responded to index. Actions: add_comment, add_to_favs,
cast_vote, create, destroy, new, preload, rescue_all_exceptions, and
show

Again, it doesn’t show an error in the logs, and the user doesn’t get a
site error.