# Routes.rb

**URL:** <https://www.ruby-forum.com/t/routes-rb/155656>\
**Category:** Rails\
**Created:** [December 15, 2008, 11:09am UTC](https://www.ruby-forum.com/t/routes-rb/155656 "2008-12-15T11:09:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [December 15, 2008, 11:09am UTC](https://www.ruby-forum.com/t/routes-rb/155656/1 "2008-12-15T11:09:58Z")

</div>

Hi,

I am going through a tutorial in a rails book. I have Something off with  
routes:  
I have RESTful resource in routes.rb:

“…  
map.resources :users, :member =\> { :enable =\> :put } do |users|  
users.resources :roles  
end  
…”

and in a html.erb partial I have:  
“…  
\<%= link\_to ‘assign role’,  
role\_url(:id =\> role.id, :user\_id =\> @user.id),  
:method =\> :put %\>  
…”  
I get:  
NoMethodError in Roles#index

Showing roles/\_role.html.erb where line #9 raised:

undefined method `role\_url’ for #ActionView::Base:0x3637bdc

I might be using newer version of rails than the book. The role\_url is  
not an explicitly defined route in this tutorial routes.rb file, I don’t  
know enough about RoR, but I am guessing the role\_url should be  
automatically available, so I would appreciate any help with this  
because my RoR learning is halted here.  
Cheers,  
Mark

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [December 15, 2008, 11:25am UTC](https://www.ruby-forum.com/t/routes-rb/155656/2 "2008-12-15T11:25:05Z")

</div>

If you nest your resources as you do, then  
the url will need all parts of it like:

user\_role\_path(@user, role)

As parameters it takes the resource ids as default,  
so you don’t need the :id and the :user\_id here

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [December 15, 2008, 11:27am UTC](https://www.ruby-forum.com/t/routes-rb/155656/3 "2008-12-15T11:27:26Z")

</div>

and don’t forget that you can use rake routes to see all your  
available routes at any given time, and their corresponding  
controllers and actions.
