# Help from Routing guru

**URL:** <https://www.ruby-forum.com/t/help-from-routing-guru/196963>\
**Category:** Rails\
**Created:** [May 23, 2009, 4:34pm UTC](https://www.ruby-forum.com/t/help-from-routing-guru/196963 "2009-05-23T16:34:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [May 23, 2009, 4:34pm UTC](https://www.ruby-forum.com/t/help-from-routing-guru/196963/1 "2009-05-23T16:34:16Z")

</div>

using such route :

map.namespace(:hubs) do |hub|  
hub.resources :settings,  
:member =\> { :general =\> :get }  
end

I get :

general\_hubs\_setting  
/hubs/settings/:id/general  
{:action=\>“general”, :controller=\>“hubs/settings”}

but I would like to get  
/hubs/:id/settings/general  
{:action=\>“general”, :controller=\>“hubs/settings” with params[:id] =  
1

what kind of route I should use ?

thanks for your help

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [May 23, 2009, 6:03pm UTC](https://www.ruby-forum.com/t/help-from-routing-guru/196963/2 "2009-05-23T18:03:55Z")

</div>

Well you have a namespace for hubs thats why there is no id for the  
hubs

map.resources :hubs do |hub|  
hub.resources :settings, :collection =\> { :general =\> :get }  
end

That will give you this:

/hubs/:hub\_id/settings/general

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [May 23, 2009, 6:30pm UTC](https://www.ruby-forum.com/t/help-from-routing-guru/196963/3 "2009-05-23T18:30:29Z")

</div>

Freddy A. wrote:

> Well you have a namespace for hubs thats why there is no id for the  
> hubs
> 
> map.resources :hubs do |hub|  
> hub.resources :settings, :collection =\> { :general =\> :get }  
> end
> 
> That will give you this:
> 
> /hubs/:hub\_id/settings/general

Thanks Fred…  
( I was reading the most recent doc ‘Rails Routing from the Outside In’  
but I just started few minutes ago… )  
this is fine but general should be a resource ( action will be standard  
‘edit’) I’ll have also permissions, profile and personal… (and one  
setting per hub)  
so I wrote

map.resources :hubs do |hub|  
hub.resource :settings do |setting|  
setting.resource :general, :controller =\> “hub/settings/general”  
end  
end

this gives me :

edit\_hub\_settings\_general GET  
/hubs/:hub\_id/settings/general/edit(.:format)  
{:action=\>“edit”, :controller=\>“hub/settings/general”}

which is fine…

I have a general.rb in app/controllers/hub/settings  
however, when executing I get the following error :

uninitialized constant Hub::Settings::GeneralController

how should I name my class ?

erwin

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [May 23, 2009, 6:41pm UTC](https://www.ruby-forum.com/t/help-from-routing-guru/196963/4 "2009-05-23T18:41:05Z")

</div>

> edit\_hub\_settings\_general GET  
> /hubs/:hub\_id/settings/general/edit(.:format)  
> {:action=\>“edit”, :controller=\>“hub/settings/general”}
> 
> which is fine…
> 
> I have a general.rb in app/controllers/hub/settings  
> however, when executing I get the following error :
> 
> uninitialized constant Hub::Settings::GeneralController
> 
> how should I name my class ?
> 
> erwin

GOT IT…  
I used: class Hub::Settings::GeneralController \< ApplicationController  
but I did a mistake  
I should use a general\_controller.rb , not general.rb

thanks for your tip !
