Routing Problem using 2.0.1

I've run into a problem upgrading an app to rails 2.0.1. All of this
worked under 1.2.6, but I'm not sure if the problem is caused by a bug
or changed behavior in 2.0.1.

this routing:
map.resources :bands do |t|
  t.resources :instruments
  t.resources :instruments, :collection => {:review => :get}
end

generates this when i run rake routes
review_band_instruments GET /bands/:band_id/instruments/review
{:action=>"review", :controller=>"instruments"}

this method
review_band_instruments_path(1)

produces this path
/bands/1/instruments/review

which erroneously generates these parameters:
Parameters: {"action"=>"show", "id"=>"review",
"controller"=>"instruments", "band_id"=>"1"}

and this error message:
ActiveRecord::RecordNotFound (Couldn't find Source with ID=review AND
(instruments.band_id = 1))

under 1.2, this all worked properly with the following parameters:
Parameters: {"action"=>"review", "controller"=>"instruments",
"band_id"=>"1"}

Any help appreciated.

I’m not sure whether duplication is causing your problem, but I’ve never seen anything like this

map.resources :bands do |t|
t.resources :instruments
t.resources :instruments, :collection => {:review => :get}

end

In the apps that I’ve worked on so far (I’ve only been doing Rails for a little over 3 months), my partners and I have only found it necessary to declare t.resources once, whether or not we also declare :member and :collection.

map.resources :bands do |t|
t.resources :instruments, :collection => {:review => :get}
end

Does that make a difference?

Craig

Duplication of resources doesn't cause the problem. The routes and
paths get specified properly. The problem occurs when rails translates
the URLs into the wrong params.

Thanks, Josh!

bbebop wrote:

Duplication of resources doesn't cause the problem. The routes and
paths get specified properly. The problem occurs when rails translates
the URLs into the wrong params.

Duplication is most certainly the problem. If you do 'rake routes'
you'll see the routes listed in match order. Notice that you have this
unnamed route:

GET /bands/:band_id/instruments/:id {:controller=>"instruments",
:action=>"show"}

above this named route:

review_band_instruments GET /bands/:band_id/instruments/review
{:controller=>"instruments", :action=>"review"}

Routes match in the order they are defined. However, the second time you
call t.resources :instruments with the :collection option you re-define
the named routes. So you are generating the latter route above but
matching the former, ending up with the #show action. Take out the first
route and all will be well.