I am experiencing some difficulties using :path_prefix on resources.
I do the following
$ rails pathtest
$ cd pathtest
$ script/generate scaffold thing title:string
$ rake db:migrate
Then in routes.rb I change:
map.resources :things
to
map.resources :things, :path_prefix => ‘:blah’
And doing a rake routes I get the following:
things GET /:blah/things
{:action=>“index”, :controller=>“things”}
formatted_things GET /:blah/things.:format
{:action=>“index”, :controller=>“things”}
POST /:blah/things
{:action=>“create”, :controller=>“things”}
POST /:blah/things.:format
{:action=>“create”, :controller=>“things”}
new_thing GET /:blah/things/new
{:action=>“new”, :controller=>“things”}
formatted_new_thing GET /:blah/things/new.:format
{:action=>“new”, :controller=>“things”}
edit_thing GET /:blah/things/:id/edit
{:action=>“edit”, :controller=>“things”}
formatted_edit_thing GET /:blah/things/:id/edit.:format
{:action=>“edit”, :controller=>“things”}
thing GET /:blah/things/:id
{:action=>“show”, :controller=>“things”}
formatted_thing GET /:blah/things/:id.:format
{:action=>“show”, :controller=>“things”}
PUT /:blah/things/:id
{:action=>“update”, :controller=>“things”}
PUT /:blah/things/:id.:format
{:action=>“update”, :controller=>“things”}
DELETE /:blah/things/:id
{:action=>“destroy”, :controller=>“things”}
DELETE /:blah/things/:id.:format
{:action=>“destroy”, :controller=>“things”}
/:controller/:action/:id
/:controller/:action/:id.:format
But…
got to localhost:3000/my/things works fine. I create a new thing.
Then I get this error:
thing_url failed to generate from {:action=>“show”, :blah=>#<Thing id:
1, title: “test”, created_at: “2008-07-28 07:55:27”, updated_at:
“2008-07-28 07:55:27”>, :controller=>“things”}, expected:
{:action=>“show”, :controller=>“things”}, diff: {:blah=>#<Thing id: 1,
title: “test”, created_at: “2008-07-28 07:55:27”, updated_at:
“2008-07-28 07:55:27”>}
And I can no longer go to /my/things because of that error.
It seems that when it is trying to create
(eval):17:in `thing_path’
the :blah value is not being set.
I have to edit all my views to do this:
<td><%= link_to 'Show', thing_path(params[:blah], thing) %></td>
instead of
I think this is a bug in rails… or am I misunderstanding how this
should work?