# Nested routes and a missing method

**URL:** <https://www.ruby-forum.com/t/nested-routes-and-a-missing-method/178875>\
**Category:** Rails\
**Created:** [November 12, 2009, 8:29pm UTC](https://www.ruby-forum.com/t/nested-routes-and-a-missing-method/178875 "2009-11-12T20:29:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [November 12, 2009, 8:29pm UTC](https://www.ruby-forum.com/t/nested-routes-and-a-missing-method/178875/1 "2009-11-12T20:29:32Z")

</div>

I have this nested route:

map.resource :users do |user|  
user.resources :roles  
end

Which, among others, gives me this named routing, user\_roles:

```
user_roles GET /users/:user_id/roles

```

(.:format)  
{:controller=\>“roles”, :action=\>“index”}

However, when I try using “link\_to to user\_roles” I get this method  
missing error. What am I doing wrong?

NameError in Users#show

Showing app/views/users/show.html.erb where line #59 raised:

undefined local variable or method `user\_roles’ for #\<ActionView::Base:  
0x2aaaac0c3bf0\>

Extracted source (around line #59):

57:  
58: \<%= link\_to ‘View This Account’s Assigned Roles’,  
59: user\_roles,  
60: :id =\> ‘user\_roles\_link’%\>  
61:

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [November 12, 2009, 10:40pm UTC](https://www.ruby-forum.com/t/nested-routes-and-a-missing-method/178875/2 "2009-11-12T22:40:40Z")

</div>

On Nov 12, 2:22 pm, byrnejb [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Extracted source (around line #59):
> 
> 57:  
> 58: \<%= link\_to ‘View This Account's Assigned Roles’,  
> 59: user\_roles,  
> 60: :id =\> ‘user\_roles\_link’%\>  
> 61:

Should be instead:

57:  
58: \<%= link\_to ‘View This Account's Assigned Roles’,  
59: user\_roles\_path,  
60: :id =\> ‘user\_roles\_link’%\>  
61:

Sigh…
