spree / spree

An open source eCommerce platform giving you full control and customizability. Modular and API-first. Build any eCommerce solution that your business requires. Developed by @vendo-dev
https://spreecommerce.org
Other
13.07k stars 4.95k forks source link

ProductsHelper not available in partial 'shared/_products.html.erb' #10097

Open grll opened 4 years ago

grll commented 4 years ago

I am following the tutorial to create a simple sale extension from the documentation: https://guides.spreecommerce.org/developer/tutorials/extensions_tutorial.html

when trying to display the product in sale I have a NoMethodError in Spree::Home#sale: undefined method cache_key_for_products' for #<#<Class:0x00007fa2074674f8>:0x00007fa207464eb0>

After investigation it seems that I can't access ProductsHelper method cache_key_for_products in the partial _products.html.erb.

Context

Following the tutorial https://guides.spreecommerce.org/developer/tutorials/extensions_tutorial.html

Expected Behavior

I can access ProductHelpers in partials.

Actual Behavior

I can't access ProductHelpers in products partials.

Steps to Reproduce

Follow the creating extension tutorial up to 'Viewing On Sale Products'

Your Environment

kirykr commented 4 years ago

I still got the same issue. I also follow the fixed issue #9940 though.

kirykr commented 4 years ago

I fixed the issue by including Spree::ProductsHelper in the ApplicationHelper in the my_store directory

  module ApplicationHelper
    include Spree::ProductsHelper
  end