2016-04-04 5 views
0

Ich habe eine vorhandene Dekorateur, die wie folgt aussieht:Warum bekomme ich eine nicht initialisierte Konstante Spree :: Admin :: CheckoutsController (NameError) für meinen Dekorateur?

app/controllers/products_controller_decorator.rb

1 module Spree 
    2 Admin::ProductsController.class_eval do 
    3  def update_stock_location 
      # my custom code 

^, das funktioniert.

Aber wenn ich versuche, einen neuen Dekorateur für die CheckoutsController zu erstellen, bekomme ich diesen Fehler:

app/controllers/checkouts_controller_decorator.rb:2:in 
`<module:Spree>': uninitialized constant Spree::Admin::CheckoutsController (NameError) 
     from /Users/martins/Work/SolidusApp/app/controllers/checkouts_controller_decorator.rb:1:in `<top (required)>' 
     from /Users/martins/.rvm/gems/[email protected]/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require' 
     from /Users/martins/.rvm/gems/[email protected]/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require' 
     from /Users/martins/Work/SolidusApp/config/application.rb:24:in `block (2 levels) in <class:Application>' 

Das ist, was meine Spree :: Admin :: CheckoutsController wie folgt aussieht: app/controllers /checkouts_controller_decorator.rb

1 module Spree 
    2 Admin::CheckoutsController.class_eval do 
    3 
    4  def complete 
      # my custom code 

ich verstehe nicht, warum es eine uninitialized constant Spree::Admin::CheckoutsController (NameError) bekommen. Die Dateien sehen identisch aus.

Dies ist die ursprüngliche Klasse:

Solidus/api/app/controllers/Spree/api/checkouts_controller.rb

1 module Spree 
    2 module Api 
    3  class CheckoutsController < Spree::Api::BaseController 

Antwort

0

Sie wollen Api::CheckoutsController nicht Admin::CheckoutsController

module Spree 
    Api::CheckoutsController.class_eval do 
    # ... 

Andere, die finden Sie diese Antwort möglicherweise für (Singular, keine 's' nach dem Kauf)

+0

Nein, tut mir leid, das ist nicht korrekt. Ich habe den Beitrag mit einigen Auszügen aus der ursprünglichen Klasse aktualisiert. – martins

+0

@martins dann wollen Sie 'Api :: CheckoutsController' nicht' Admin :: CheckoutsController' – Shelvacu

+0

DAS IST ES! :-D Kann nicht glauben, dass ich das selbst nicht gesehen habe. Vielen Dank! – martins

Verwandte Themen