# Nested route with collection

**URL:** <https://discuss.rubyonrails.org/t/nested-route-with-collection/58403>\
**Category:** rubyonrails-talk\
**Created:** [April 13, 2011, 6:21am UTC](https://discuss.rubyonrails.org/t/nested-route-with-collection/58403 "2011-04-13T06:21:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vladimir\_Shakirov](https://avatars.discourse-cdn.com/v4/letter/v/e19b73/32.png) [@Vladimir\_Shakirov](https://discuss.rubyonrails.org/u/Vladimir_Shakirov)\
**Post date:** [April 13, 2011, 6:21am UTC](https://discuss.rubyonrails.org/t/nested-route-with-collection/58403/1 "2011-04-13T06:21:46Z")

</div>

Hi!

I try to do nested route with collection, but I always have mistake route: resources :user do &nbsp;&nbsp;resources :todo do

&nbsp;&nbsp;member do &nbsp;&nbsp;&nbsp;&nbsp;post :complete &nbsp;&nbsp;end

&nbsp;&nbsp;collection do &nbsp;&nbsp;&nbsp;&nbsp;get :completed &nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;resources :post &nbsp;&nbsp;end end

View: \<%= link\_to\_if (params[:action] == 'home'), 'Done', comoleted\_user\_todo\_path %\>

Browser back me mistake undefined local variable or method `long\_product\_category\_path' for #\<#\<class:0x1036ed8c8\>:0x1036e92a0 \</class:0x1036ed8c8\>

Could you help

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [April 13, 2011, 10:54am UTC](https://discuss.rubyonrails.org/t/nested-route-with-collection/58403/2 "2011-04-13T10:54:01Z")

</div>

> Hi!
> 
> I try to do nested route with collection, but I always have mistake route: resources :user do resources :todo do
> 
> member do post :complete end
> 
> collection do get :completed end
> 
> ```
> resources :post
> 
> ```
> 
> end end
> 
> View: \<%= link\_to\_if (params[:action] == 'home'), 'Done', comoleted\_user\_todo\_path %\>

you've got a typo there

> Browser back me mistake undefined local variable or method `long\_product\_category\_path' for #\<#\<class:0x1036ed8c8\>:0x1036e92a0 \</class:0x1036ed8c8\>

if you run rake routes it will tell you the names of all your routes

Fred

---

<div class="post-metadata">

**Author:** ![Vladimir\_Shakirov](https://avatars.discourse-cdn.com/v4/letter/v/e19b73/32.png) [@Vladimir\_Shakirov](https://discuss.rubyonrails.org/u/Vladimir_Shakirov)\
**Post date:** [April 13, 2011, 11:42am UTC](https://discuss.rubyonrails.org/t/nested-route-with-collection/58403/3 "2011-04-13T11:42:21Z")

</div>

I run rake routes comoleted\_user\_todo

I did it But situation the same undefined local variable or method `comoleted\_user\_todo\_path'

---

<div class="post-metadata">

**Author:** ![Bryan\_Crossland](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@Bryan\_Crossland](https://discuss.rubyonrails.org/u/Bryan_Crossland)\
**Post date:** [April 13, 2011, 1:21pm UTC](https://discuss.rubyonrails.org/t/nested-route-with-collection/58403/4 "2011-04-13T13:21:11Z")

</div>

> I run rake routes comoleted\_user\_todo
> 
> I did it But situation the same undefined local variable or method `comoleted\_user\_todo\_path'
> 
> > > Hi!
> > 
> > > I try to do nested route with collection, but I always have mistake route: resources :user do &nbsp;&nbsp;resources :todo do
> > 
> > > &nbsp;&nbsp;member do &nbsp;&nbsp;&nbsp;&nbsp;post :complete &nbsp;&nbsp;end
> > 
> > > &nbsp;&nbsp;collection do &nbsp;&nbsp;&nbsp;&nbsp;get :completed &nbsp;&nbsp;end
> > 
> > > &nbsp;&nbsp;&nbsp;&nbsp;resources :post &nbsp;&nbsp;end end
> > 
> > > View: \<%= link\_to\_if (params[:action] == 'home'), 'Done', comoleted\_user\_todo\_path %\>
> > 
> > you've got a typo there

Like Fred said, typo. There is no comoleted\_user\_todo\_path but there is a completed\_user\_todo\_path.

B.

---

<div class="post-metadata">

**Author:** ![Vladimir\_Shakirov](https://avatars.discourse-cdn.com/v4/letter/v/e19b73/32.png) [@Vladimir\_Shakirov](https://discuss.rubyonrails.org/u/Vladimir_Shakirov)\
**Post date:** [April 13, 2011, 1:30pm UTC](https://discuss.rubyonrails.org/t/nested-route-with-collection/58403/5 "2011-04-13T13:30:02Z")

</div>

Sorry It’s my mistake when i typed here In my code completed\_user\_todo\_path

And in route collection do get :completed end

---

<div class="post-metadata">

**Author:** ![Jim\_Ruther\_Nill](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@Jim\_Ruther\_Nill](https://discuss.rubyonrails.org/u/Jim_Ruther_Nill)\
**Post date:** [April 14, 2011, 2:51am UTC](https://discuss.rubyonrails.org/t/nested-route-with-collection/58403/6 "2011-04-14T02:51:13Z")

</div>

> Sorry It’s my mistake when i typed here In my code completed\_user\_todo\_path

it’s a bit weird but your routes look like [http://pastie.org/1793800](http://pastie.org/1793800) so use

```ruby
completed_user_todo_index_path
```
