# Routing problem

**URL:** <https://discuss.rubyonrails.org/t/routing-problem/52870>\
**Category:** rubyonrails-talk\
**Created:** [July 10, 2010, 5:38pm UTC](https://discuss.rubyonrails.org/t/routing-problem/52870 "2010-07-10T17:38:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leonardo\_Mateo](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@Leonardo\_Mateo](https://discuss.rubyonrails.org/u/Leonardo_Mateo)\
**Post date:** [July 10, 2010, 5:38pm UTC](https://discuss.rubyonrails.org/t/routing-problem/52870/1 "2010-07-10T17:38:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [July 10, 2010, 6:26pm UTC](https://discuss.rubyonrails.org/t/routing-problem/52870/2 "2010-07-10T18:26:25Z")

</div>

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]

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

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

Sijo

---

<div class="post-metadata">

**Author:** ![Leonardo\_Mateo](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@Leonardo\_Mateo](https://discuss.rubyonrails.org/u/Leonardo_Mateo)\
**Post date:** [July 10, 2010, 8:40pm UTC](https://discuss.rubyonrails.org/t/routing-problem/52870/3 "2010-07-10T20:40:34Z")

</div>

> 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!
