A space to discuss online store customization, theme development, and Liquid templating.
I'm building a shopify app-proxy using ruby on rails. i’m using the shopify_app gem.
in my controller actions i have the following set:
render layout: false, content_type: ‘application/liquid'
- so that the app is embedded within the shop’s layout/theme.liquid.
my question is how do i then pull assets into the app? I’ve tried including them manually into the template files using:
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
but alas, i get 404 not found errors. currently i’m putting asset files into the store’s theme which doesn’t seem ideal.
Hey did you manage to figure this out? Could it have something to do with the way Rails fingerprints the assets?
EDIT (SOLVED): I was recieving 404s because the asset host domain was getting changed to the shopify store's domain. In order for Rails to find your assets you need to specify the domain in your production enviroment (production.rb):
config.action_controller.asset_host = "https://your-custom-domain-or-herokuapp-domain.com"
Hope this helps!
Thanks Matias!
Hi sir it does work in older versions of rails but in rails 7 using importmaps how do I achieve the same , any kind help would be appreciated
thanks
Thanks, Matias! This was driving me nuts.