Есть ли способ упростить вложенные ресурсы пространства имен? - PullRequest
0 голосов
/ 13 июня 2011

Есть ли менее излишний способ сделать это?

resources :tournaments do
    resources :commitments,     controller: "tournaments/commitments"
    resources :constraints,     controller: "tournaments/constraints"
    resources :entries,         controller: "tournaments/entries"
    resources :buildings,       controller: "tournaments/buildings" do
        resources :rooms,       controller: "tournaments/buildings/rooms"
    end
end

1 Ответ

0 голосов
/ 15 июня 2011

Это соглашение для вложенных ресурсов. Здесь все контроллеры все еще находятся в каталоге app / controllers.

resources :tournaments do
    resources :commitments
    resources :constraints
    resources :entries
    resources :buildings do
        resources :rooms
    end
end

Как правило, вы используете каталоги для своих контроллеров, когда вам нужно пространство имен, например:

namespace :admin do
  resources :users
  root :to=>"dashboards#admin"
end

#/admin/users
...