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.
49de4cd2f26705785cbef2b15a9df7aa?d=identicon&s=25 Nick Hoffman (nickh)
on 2008-11-24 20: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
4c438a80fc30661ad619ea177cf9cbd0?d=identicon&s=25 Freddy Andersen (Guest)
on 2008-11-24 21: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
49de4cd2f26705785cbef2b15a9df7aa?d=identicon&s=25 Nick Hoffman (nickh)
on 2008-11-25 04:05
(Received via mailing list)
On Nov 24, 3:54 pm, Freddy Andersen <fre...@cfandersen.com> 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.