# Map.resources for controllers in a module

**URL:** <https://www.ruby-forum.com/t/map-resources-for-controllers-in-a-module/127442>\
**Category:** Rails\
**Created:** [January 29, 2008, 8:05am UTC](https://www.ruby-forum.com/t/map-resources-for-controllers-in-a-module/127442 "2008-01-29T08:05:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [January 29, 2008, 8:05am UTC](https://www.ruby-forum.com/t/map-resources-for-controllers-in-a-module/127442/1 "2008-01-29T08:05:14Z")

</div>

Hello-

I’m giving RESTful development a shot. I’m running into some difficulty  
with controller I have grouped into modules. Specifically, I have a  
“admin” module with a “user” controller (created with “generate  
controller admin/user”). I managed to get map.resources wired up with  
this code:

map.resources Admin::User, :path\_prefix =\> “/admin”

I’m not sure if that’s the right way, but it seems to work. The problem  
I’m running into is with setting up my link\_tos. I tried this code:

\<%= link\_to ‘Show’, user\_path(@user) %\>

Which failed with a “undefined method `user\_path’ for  
#\<#Class:0x47eaa14:0x47ea9ec\>”. Not unexpected. However I can’t figure  
out the right syntax for the path to my user admin actions. Can anyone  
help?

Regards-  
Eric

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [January 29, 2008, 8:28am UTC](https://www.ruby-forum.com/t/map-resources-for-controllers-in-a-module/127442/2 "2008-01-29T08:28:29Z")

</div>

Look at namespace  
map.namespace :admin do |admin|  
admin.resources :users  
end  
gives you helpers such as this:  
\<%= link\_to ‘Show’, admin\_user\_path(@user) %\>  
also look at the very useful:

rake routes

Eric M. wrote:

> Hello-
> 
> I’m giving RESTful development a shot. I’m running into some difficulty  
> with controller I have grouped into modules. Specifically, I have a  
> “admin” module with a “user” controller (created with “generate  
> controller admin/user”). I managed to get map.resources wired up with  
> this code:
> 
> map.resources Admin::User, :path\_prefix =\> “/admin”
> 
> I’m not sure if that’s the right way, but it seems to work. The problem  
> I’m running into is with setting up my link\_tos. I tried this code:
> 
> \<%= link\_to ‘Show’, user\_path(@user) %\>
> 
> Which failed with a “undefined method `user\_path’ for  
> #\<#Class:0x47eaa14:0x47ea9ec\>”. Not unexpected. However I can’t figure  
> out the right syntax for the path to my user admin actions. Can anyone  
> help?
> 
> Regards-  
> Eric

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [January 29, 2008, 8:31am UTC](https://www.ruby-forum.com/t/map-resources-for-controllers-in-a-module/127442/3 "2008-01-29T08:31:05Z")

</div>

map.namespace :admin do  
map.resources :users  
end

admin\_user\_path(@user)

should do the trick.

On Jan 29, 2008 5:35 PM, Eric M.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## Regards- Eric
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [January 29, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/map-resources-for-controllers-in-a-module/127442/4 "2008-01-29T17:21:21Z")

</div>

This is great info. Exactly what I waslooking for. Thanks.

Regards-  
Eric

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [January 29, 2008, 10:01am UTC](https://www.ruby-forum.com/t/map-resources-for-controllers-in-a-module/127442/5 "2008-01-29T10:01:02Z")

</div>

Hi,  
Here is a perfect 2.0 RESTful nested and namespace tutorial, after  
checking u would totally understand the whole stuff. I am not doing ad  
here. cuz it really needs to recommend 🙂

> **[Rolling with Rails 2.0 - The First Full Tutorial - Part 1 | AkitaOnRails.com](https://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial)**
>
> for brazilians: click here.
> I am very happy to see that my Rails 2.0 Screencast was very well received. More than 1,500 unique visitors watched it...

On 1ÔÂ29ÈÕ, ÉÏÎç9Ê±05·Ö, Eric M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
