why uninitialized constant Spree::V2::Storefront::Product?

rails g migration AddFieldsToSpreeProducts orig_url:text

I'm trying to expand my existing model with a decorator

/app/models/AppName/spree/product_serializer_decorator.rb

  module Spree
    module ProductDecorator
      def self.prepended(base)
        base.attributes :orig_url
      end
    end
  end
end

::Spree::V2::Storefront::Product.prepend AppName::Spree::ProductDecorator if ::Spree::V2::Storefront::Product.included_modules.exclude?(AppName::Spree::ProductDecorator)

why does my passenger tell me that uninitialized constant Spree::V2::Storefront::Product? how to announce them correctly?

Upvotes: 0

Views: 384

Answers (1)

mizinsky
mizinsky

Reputation: 161

There is no constant Spree::V2::Storefront::Product.

I think you should make a decorator for ProductSerializer. Try something like this:

module Spree
  module V2
    module Storefront
      module ProductSerializerDecorator
        def self.prepended(base)
          base.attributes :orig_url
        end
      end
    end
  end
end

::Spree::V2::Storefront::ProductSerializer.prepend Spree::V2::Storefront::ProductSerializerDecorator

Upvotes: 1

Related Questions