Неинициализированная постоянная задача для маршрутов Rails - PullRequest
5 голосов
/ 14 июля 2009

Вот моя конфигурация маршрута:

map.resources :services do |services|
  services.resources :capabilities do |capabilities|
    capabilities.resources :http_headers
  end
end

Вот мой вывод "Рейк-маршруты":

laran:trunk laran$ rake routes
(in /Users/laran/workspace/kibo/mega/server/trunk)
                           accounts GET    /accounts(.:format)                                                               {:action=>"index", :controller=>"accounts"}
                                    POST   /accounts(.:format)                                                               {:action=>"create", :controller=>"accounts"}
                        new_account GET    /accounts/new(.:format)                                                           {:action=>"new", :controller=>"accounts"}
                       edit_account GET    /accounts/:id/edit(.:format)                                                      {:action=>"edit", :controller=>"accounts"}
                            account GET    /accounts/:id(.:format)                                                           {:action=>"show", :controller=>"accounts"}
                                    PUT    /accounts/:id(.:format)                                                           {:action=>"update", :controller=>"accounts"}
                                    DELETE /accounts/:id(.:format)                                                           {:action=>"destroy", :controller=>"accounts"}
                           services GET    /services(.:format)                                                               {:action=>"index", :controller=>"services"}
                                    POST   /services(.:format)                                                               {:action=>"create", :controller=>"services"}
                        new_service GET    /services/new(.:format)                                                           {:action=>"new", :controller=>"services"}
                       edit_service GET    /services/:id/edit(.:format)                                                      {:action=>"edit", :controller=>"services"}
                            service GET    /services/:id(.:format)                                                           {:action=>"show", :controller=>"services"}
                                    PUT    /services/:id(.:format)                                                           {:action=>"update", :controller=>"services"}
                                    DELETE /services/:id(.:format)                                                           {:action=>"destroy", :controller=>"services"}
               service_capabilities GET    /services/:service_id/capabilities(.:format)                                      {:action=>"index", :controller=>"capabilities"}
                                    POST   /services/:service_id/capabilities(.:format)                                      {:action=>"create", :controller=>"capabilities"}
             new_service_capability GET    /services/:service_id/capabilities/new(.:format)                                  {:action=>"new", :controller=>"capabilities"}
            edit_service_capability GET    /services/:service_id/capabilities/:id/edit(.:format)                             {:action=>"edit", :controller=>"capabilities"}
                 service_capability GET    /services/:service_id/capabilities/:id(.:format)                                  {:action=>"show", :controller=>"capabilities"}
                                    PUT    /services/:service_id/capabilities/:id(.:format)                                  {:action=>"update", :controller=>"capabilities"}
                                    DELETE /services/:service_id/capabilities/:id(.:format)                                  {:action=>"destroy", :controller=>"capabilities"}
    service_capability_http_headers GET    /services/:service_id/capabilities/:capability_id/http_headers(.:format)          {:action=>"index", :controller=>"http_headers"}
                                    POST   /services/:service_id/capabilities/:capability_id/http_headers(.:format)          {:action=>"create", :controller=>"http_headers"}
 new_service_capability_http_header GET    /services/:service_id/capabilities/:capability_id/http_headers/new(.:format)      {:action=>"new", :controller=>"http_headers"}
edit_service_capability_http_header GET    /services/:service_id/capabilities/:capability_id/http_headers/:id/edit(.:format) {:action=>"edit", :controller=>"http_headers"}
     service_capability_http_header GET    /services/:service_id/capabilities/:capability_id/http_headers/:id(.:format)      {:action=>"show", :controller=>"http_headers"}
                                    PUT    /services/:service_id/capabilities/:capability_id/http_headers/:id(.:format)      {:action=>"update", :controller=>"http_headers"}
                                    DELETE /services/:service_id/capabilities/:capability_id/http_headers/:id(.:format)      {:action=>"destroy", :controller=>"http_headers"}
                                           /login                                                                            {:action=>"login", :controller=>"accounts"}
                                           /logout                                                                           {:action=>"logout", :controller=>"accounts"}
                               root        /                                                                                 {:action=>"index", :controller=>"default"}
laran:trunk laran$ 

Когда я захожу в / services / new, я получаю эту ошибку:

NameError in ServicesController#new

uninitialized constant ServicesController::Services

Что дает? Как я могу заставить все работать и правильно маршрутизировать? Благодаря.

Ответы [ 2 ]

4 голосов
/ 14 июля 2009

Поддерживается ли ServicesController типовой службой? Вы случайно упомянули это как Services в вашем контроллере?

1 голос
/ 14 июля 2009

Вероятно, это не имеет никакого отношения к вашим маршрутам; Ваш new метод в ServicesController пытается использовать (класс? constant? object?) с именем Services, который не существует.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...