Routing problem

Hi guys,

I'm having a problem with nested routes and I don't know what I'm missing.
I have a "products" resource, which has a "available" collection action.

map.resources :courses, :member => { :confirm => :get}, :collection
=> { :available => :get }

Then I have the "users" resource, which has many "products"

map.resources :users, :has_many => [:subscriptions, :courses]

The problem is that if I try to access "available" products through a
user (/users/3/courses/available) I get redirected to the "show"
action with parameters:
Parameters: {"action"=>"show", "id"=>"available", "user_id"=>"3",
"controller"=>"products"}

I can't find the relevant section in the routing guide and I can't
figure it out.
Does anyone know what I am doing wrong?

Thanx a lot in advance.

Hi Leonardo

map.resources :courses, :member => { :confirm => :get}, :collection
=> { :available => :get }

Then I have the "users" resource, which has many "products"

map.resources :users, :has_many => [:subscriptions, :courses]

    Assuming what you specified "products" is "courses". Change your
routes as below

map.resources :users do |user|
  user.resources :courses, :member => { :confirm => :get}, :collection
=> {available => :get }
  user.resources :subscriptions
end

Sijo

Hi Leonardo

Hi Sijo

map.resources :courses, :member => { :confirm => :get}, :collection
=> { :available => :get }

Then I have the "users" resource, which has many "products"

map.resources :users, :has_many => [:subscriptions, :courses]

Assuming what you specified "products" is "courses". Change your
routes as below

Yes, sorry, I mixed two applications with the same problem here.

map.resources :users do |user|
user.resources :courses, :member => { :confirm => :get}, :collection
=> {available => :get }
user.resources :subscriptions
end

This worked like a charm.
Thanx a lot!