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

Create _essence_spree_product_view and _essence_spree_taxon_view when running installer #36

Closed
rickythefox opened this issue Mar 27, 2019 · 11 comments

Comments

@rickythefox
Copy link
Contributor

rickythefox commented Mar 27, 2019

Shouldn't the installer create
app/views/alchemy/essences/_essence_spree_product_view.html.erb and
app/views/alchemy/essences/_essence_spree_taxon_view.html.erb
and perhaps also add some dafaults (like <%= content.ingredient.name %>) to them?

As it is, nothing is displayed when rendering the generated page, which is a bit confusing.

@tvdeyen
Copy link
Member

tvdeyen commented Mar 27, 2019

Those files live in this gem and will be picked up by Rails Template lookup if no such file exists in the host app.

This said, are you sure you have a Taxon or product assigned in the backend?

@rickythefox
Copy link
Contributor Author

IMO the installer should copy the files to the user application. _essence_spree_product_view is empty by default, so when you create an Alchemy page with a Solidus product, nothing is shown.

You have to dig in the gem code to understand that you have to create app/views/alchemy/essences/_essence_spree_product_view.html.erb and use content.ingredient to get the Solidus product object. That is not in the docs what I've seen.

@tvdeyen
Copy link
Member

tvdeyen commented Mar 28, 2019

Ok, know I see the confusion. Sorry.

I usually have the product rendering logic in my element that uses the EssenceSpreeProduct.

# app/views/alchemy/product_teaser.html.erb
<%= element_view_for element do |el| %>
  <% product = el.ingredient(:product) %>
  Price: <%= product.display_price %>
  ...
<% end %>

That way I can have multiple representations for the same product. The same is true for taxons.

# app/views/alchemy/taxon_teaser.html.erb
<%= element_view_for element do |el| %>
  <% taxon = el.ingredient(:taxon) %>
  Products count: <%= taxon.products.count %>
  ...
<% end %>

There is no advantage having this logic inside your essence product partials. That's why they are empty. Sorry, if that is not very obvious from the Readme.

@rickythefox
Copy link
Contributor Author

rickythefox commented Mar 28, 2019

Got it, thanks. Might be a useful snippet to add to the readme. :) The You can haz Solidus product and taxons! section is not super clear about where element comes from, might be useful with some more code for those of us new to Alchemy.

@tvdeyen
Copy link
Member

tvdeyen commented Mar 28, 2019

@rickythefox yes, you are absolutely right. Thanks for reporting. Any chance you have time to provide a PR with that change? Maybe you have other things to add to the README as well that would help other newcomers?

@rickythefox
Copy link
Contributor Author

Of course, will submit a PR next week.

@tvdeyen
Copy link
Member

tvdeyen commented Mar 28, 2019

Awesome. Thank you!

@tvdeyen
Copy link
Member

tvdeyen commented Aug 9, 2019

@rickythefox updated the README in #46 and included the element examples

@tvdeyen tvdeyen closed this as completed Aug 9, 2019
@rickythefox
Copy link
Contributor Author

Thank you! Completely forgot that I promised a PR, sorry about that!

@tvdeyen
Copy link
Member

tvdeyen commented Aug 10, 2019 via email

@rickythefox
Copy link
Contributor Author

@tvdeyen I think the examples are great! Thanks for taking the time to write them.

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

2 participants