Skip to content

Compatibility with spree_static_content extension #32

Description

@Wootenblatz

I am working on a project that uses this extension and spree_static_content. After getting this extension running all of my static content pages threw an error as follows:

ActionView::Template::Error (undefined method available_facets' for nil:NilClass): 1: <nav id="taxonomies" class="sidebar-item" data-hook><% 2: facets = @searcher.available_facets || [] 3: taxon_names = @taxon ? @taxon.self_and_descendants.map(&:name) : [] 4: for facet in facets 5: options = facet.options spree_core (1.3.2) app/views/spree/shared/_taxonomies.html.erb:2:in_ea1d5b61095c876e70e1dc33471f3255'

With a little digging I can see this error started showing up because of the override to put facets in the sidebar. spree_static_content's main controller inherits from Spree::StoreController and probably is not creating the corresponding @searcher variable that _facets.html.erb is expecting.

A conditional inside the facets partial solved this problem for me. That strikes me as more of a bandaid than an actual fix. Because other extensions may update/pollute/change the sidebar in spree it seems like the @searcher variable needs to be instantiated in a more persistant way? Unfortunately I do not know enough about this extension yet to say if that is worth doing or even the right solution.

I did publish my quick fix for this and can issue a pull request if you like:
Wootenblatz@e49fccd

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions