-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Element views not rendering from Solidus #1626
Comments
Very interesting. Thanks for reporting. This seems to be a namespacing issue. What controller scope are you running this views code in? |
Spree. This code is on my "spree/layouts/spree_application.html.erb". The controller is Spree::ProductsController |
Rails will by default prepend the controller namespace to the partials path. If you render your Elements inside a view rendered by a namespaced controller rails uses the The only way to get around this maybe to MonkeyPatch module Alchemy::ElementsHelper
def disable_controller_naymspace_in_partial_path
ActionView::Base.prefix_partial_path_with_controller_namespace = false
end
def enable_controller_naymspace_in_partial_path
ActionView::Base.prefix_partial_path_with_controller_namespace = true
end
alias_method :old_render_element, :render_element
def render_element(*args)
disable_controller_naymspace_in_partial_path
content = old_render_element(*args)
enable_controller_naymspace_in_partial_path
content
end
end @tvdeyen this breaks every usage of element views in plugin engines (if they use |
@DennisNissen thanks for the detailed report. Maybe it helps to prefix the path from Can you please try to override |
I think that was the first thing i tried, but it did not work. I would be sufficient if |
Reading this over and over again and I think this is odd behavior from Rails. Alchemy itself is an isolated and name spaced engine. Since we explicitly add the Either Rails is magically removing duplicated namespaces or we miss something here. I think we should disable This action view feature is very confusing. |
If you want to render alchemy elements in a Solidus controller namespace, we need to disable prefixing of controller path to partial paths, or we get an extra `spree` namespace for the element partial paths and the elements wont render. Closes AlchemyCMS/alchemy_cms#1626
@gabrielrios @DennisNissen created AlchemyCMS/alchemy-solidus#53 Could you try this in your apps and report if this fixes your issue and does not introduce new ones? |
@tvdeyen I can confirm this works. |
If you want to render alchemy elements in a Solidus controller namespace, we need to disable prefixing of controller path to partial paths, or we get an extra `spree` namespace for the element partial paths and the elements wont render. Closes AlchemyCMS/alchemy_cms#1626
Steps to reproduce
If you try to render a Element from inside a solidus page
The element won't render, only showing
<!-- Missing view for element -->
.It tries to render
app/views/spree/alchemy/elements/element_view
instead ofapp/views/alchemy/elements/element_view
This worked fine on Alchemy 4.1, I'm guessing this is related to
render_elements
changes on #1553 and #1554System configuration
The text was updated successfully, but these errors were encountered: