Forum: Ruby on Rails help from Routing guru ...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2009-05-23 16:34
(Received via mailing list)
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
4c438a80fc30661ad619ea177cf9cbd0?d=identicon&s=25 Freddy Andersen (Guest)
on 2009-05-23 18:03
(Received via mailing list)
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
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2009-05-23 18:30
Freddy Andersen 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
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2009-05-23 18:41
> 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 !
This topic is locked and can not be replied to.