Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alchemy pages helper disappears on checkout, 500 error #61

Closed
hrdchz opened this issue Apr 2, 2020 · 4 comments
Closed

Alchemy pages helper disappears on checkout, 500 error #61

hrdchz opened this issue Apr 2, 2020 · 4 comments

Comments

@hrdchz
Copy link
Contributor

hrdchz commented Apr 2, 2020

Describe the bug

We are building an "Alchemy in Solidus" site.

I used PagesHelper#render_menu to display menus on a solidus site, using bundle exec rails g solidus:views:override. The menus render on product, taxon, cart pages but at /checkout/address (first step of checkout) we get the error:

ActionView::Template::Error (undefined method `render_menu' for #<#<Class:0x00007fa1a70a1d88>:0x00007fa1a70aa938>
Did you mean?  render):

To Reproduce
Steps to reproduce the behavior:

  1. start an alchemy in Solidus project
  2. Create a Menu in Alchemy
  3. Render that menu in you app's frontend
  4. Add an item to cart, proceed to checkout

Expected behavior
The menus should render on the checkout page and the render_menu function should be available in the checkout pages.

Screenshots
None

Gems in your Gemfile:

  • alchemy-solidus (3.0.2)
  • alchemy_cms (4.4.4)
  • solidus (2.9.5)
  • Rails 5.2.4.1 / ruby 2.6.5

Additional context
I don't know where to look to sort this out and PR it. I am not sure where the helpers get passed to Solidus. I can investigate if pointed in the right direction.

@hrdchz
Copy link
Contributor Author

hrdchz commented Apr 2, 2020

ok so I entered debugger in my template to try and understand this a little better.

defined? Alchemy::PageHelpers is true, but the function is not defined. CheckoutController is a StoreController, but it does have this line:

    helper 'spree/orders'

I'm not familiar enough with Rails to know this, but I have an intuition that perhaps the helper method is doing something to dis-include these helpers? I'll mess with this when I have time.

As a workaround the obvious (suboptimal) solution is to just check the method is defined in my template.

@mickenorlen
Copy link

I had a similar problem before. This seems to happen when rendering the menu from a "nested" controller class.
For example if you have Shop::CheckoutController Instead of just CheckoutController.
Then i think render_menu looks after the partials in the nested folders views/shop/ instead of the root views/.
For quick fix before fixed, try copying something like views/alchemy/menus/main_menu/...
over to views/shop/alchemy/menus/main_menu/...

@hrdchz
Copy link
Contributor Author

hrdchz commented May 4, 2020

I was able to resolve the problem by simply adding the helpers into my application like so:

module ApplicationHelper
  include Alchemy::ElementsHelper
  include Alchemy::PagesHelper
  #...
end

I added the ElementsHelper as well since I was having an issue where that helper was not showing up in my Orders page. Strangely enough, the elements had previously been rendering. I'm not certain what exactly changed.

This certainly works, I just don't know if it's the most correct solution.

@tvdeyen
Copy link
Member

tvdeyen commented Jan 4, 2021

Either that or include the modules in the controllers you are using. It should already be dealt with in this gem. If this does not work by explicitly requiring 'alchemy/solidus/alchemy_in_solidus' in one of your initializers.

@tvdeyen tvdeyen closed this as completed Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants