Forum: Ruby on Rails Namespacing conventions

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.
Nick H. (Guest)
on 2008-11-24 21:50
(Received via mailing list)
I compared the output from ``rake routes'' for each solution below,
and they both produce the exact same routes. Is one solution preferred
over the over?

# Solution #1:
map.resource  :account do |account|
   account.resources :properties, :controller => 'account/properties'
   account.resources :photos, :controller => 'account/photos'
end

# Solution #2:
map.resource  :account
map.namespace :account do |account|
   account.resources :photos
   account.resources :properties
end

Cheers,
Nick
Freddy A. (Guest)
on 2008-11-24 22:54
(Received via mailing list)
I guess you have the answer in your question... You don't need the
controller part so it would look like this:

map.resource  :account do |account|
   account.resources :properties
   account.resources :photos
end
Nick H. (Guest)
on 2008-11-25 05:05
(Received via mailing list)
On Nov 24, 3:54 pm, Freddy A. <removed_email_address@domain.invalid> wrote:
> I guess you have the answer in your question... You don't need the
> controller part so it would look like this:
>
> map.resource  :account do |account|
>    account.resources :properties
>    account.resources :photos
> end

Hi Freddy. Leaving out the :controller part results in the properties
and photos nested resources using their non-namespaced controllers:
http://rafb.net/p/lODGyE45.html
This topic is locked and can not be replied to.