5 Stimmen

Uninitialisierte Konstante Problem für Rails Routen

Hier ist meine Routenkonfiguration:

map.resources :services do |services|
  services.resources :capabilities do |capabilities|
    capabilities.resources :http\_headers
  end
end

Hier ist die Ausgabe meiner "Rake-Routen":

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$ 

Wenn ich jedoch zu /services/new gehe, erhalte ich diesen Fehler:

NameError in ServicesController#new

uninitialized constant ServicesController::Services

Was ist los? Wie kann ich die Dinge zum Laufen bringen und richtig verlegen? Vielen Dank!

4voto

Ben Hughes Punkte 13721

Wird ServicesController durch einen Modelldienst unterstützt? Haben Sie es versehentlich als Services in Ihrem Controller referenziert?

1voto

Jim Puls Punkte 75380

Das hat wahrscheinlich nichts mit Ihren Routen zu tun; Ihre new Methode in ServicesController versucht, eine (Klasse? Konstante? Objekt?) namens Services die es nicht gibt.

CodeJaeger.com

CodeJaeger ist eine Gemeinschaft für Programmierer, die täglich Hilfe erhalten..
Wir haben viele Inhalte, und Sie können auch Ihre eigenen Fragen stellen oder die Fragen anderer Leute lösen.

Powered by:

X