# Routing problem

**URL:** <https://www.ruby-forum.com/t/routing-problem/191369>\
**Category:** Rails\
**Created:** [July 10, 2010, 7:40pm UTC](https://www.ruby-forum.com/t/routing-problem/191369 "2010-07-10T19:40:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leo72](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/71c47a/32.png) [@leo72](https://www.ruby-forum.com/u/leo72)\
**Post date:** [July 10, 2010, 7:40pm UTC](https://www.ruby-forum.com/t/routing-problem/191369/1 "2010-07-10T19:40:01Z")

</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.

Leonardo M…  
There’s no place like ~

---

<div class="post-metadata">

**Author:** ![leo72](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/71c47a/32.png) [@leo72](https://www.ruby-forum.com/u/leo72)\
**Post date:** [July 10, 2010, 8:26pm UTC](https://www.ruby-forum.com/t/routing-problem/191369/2 "2010-07-10T20: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]

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

---

<div class="post-metadata">

**Author:** ![leo72](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/71c47a/32.png) [@leo72](https://www.ruby-forum.com/u/leo72)\
**Post date:** [July 10, 2010, 10:42pm UTC](https://www.ruby-forum.com/t/routing-problem/191369/3 "2010-07-10T22:42:04Z")

</div>

On Sat, Jul 10, 2010 at 3:26 PM, Sijo k g [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

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

–  
Leonardo M…  
There’s no place like ~
