# REST route not working

**URL:** <https://www.ruby-forum.com/t/rest-route-not-working/91149>\
**Category:** Rails\
**Created:** [April 5, 2007, 5:04am UTC](https://www.ruby-forum.com/t/rest-route-not-working/91149 "2007-04-05T05:04:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [April 5, 2007, 5:04am UTC](https://www.ruby-forum.com/t/rest-route-not-working/91149/1 "2007-04-05T05:04:52Z")

</div>

I have a nested route that doesn’t want to work for me.

In my routes.rb I have:  
/////////////  
map.resources :orders, :collection =\> { :archived =\> :get, :search =\>  
:post } do |orders|  
orders.resources :shipments, :collection =\> { :track =\> :get }  
orders.resources :addressbooks, :name\_prefix =\> “order\_”  
end  
/////////////

The problem is, I’m trying to access the track route using:  
track\_shipment\_path(order\_id, id)  
which would translate to:  
/orders/33333/shipments/111;track  
but it’s saying undefined method `track\_shipment\_path’

I’ve accessed the :archived route this way, just can’t understand why  
the track route doesn’t work.

Just wondering what I’m doing wrong.

Thanks,

Dave

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [April 5, 2007, 5:27am UTC](https://www.ruby-forum.com/t/rest-route-not-working/91149/2 "2007-04-05T05:27:46Z")

</div>

Hey,

you’ve got ‘track’ defined on the shipments collection so it would be:

track\_shipments\_path(order\_id)

But seeing as the URL you quoted is for a shipments _member_ (/orders/  
333/shipments/111;track), you probably want this:

orders.resources :shipments, :member =\> {:track =\> :get}

in which case, the helper would be (as you expected)  
track\_shipment\_path(order\_id, id)

HTH,  
Trevor

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [April 5, 2007, 4:08pm UTC](https://www.ruby-forum.com/t/rest-route-not-working/91149/3 "2007-04-05T16:08:03Z")

</div>

Trevor S. wrote:

> But seeing as the URL you quoted is for a shipments _member_ (/orders/  
> 333/shipments/111;track), you probably want this:
> 
> orders.resources :shipments, :member =\> {:track =\> :get}
> 
> in which case, the helper would be (as you expected)  
> track\_shipment\_path(order\_id, id)
> 
> HTH,  
> Trevor

Hi Trevor,

That was exactly what I needed! Thanks.

I’m having a hard time understanding the difference  
between a collection and a member. Will figure it out  
someday.

Thanks again for your help!

Dave

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [April 5, 2007, 4:13pm UTC](https://www.ruby-forum.com/t/rest-route-not-working/91149/4 "2007-04-05T16:13:37Z")

</div>

David C. wrote:

> I’m having a hard time understanding the difference  
> between a collection and a member. Will figure it out  
> someday.

And that day is the day. I finally read the part of the peepcode rest  
cheatsheet that has collections & members on there.

Learn something new everyday.
