Shopify app - how to include assets using an app-proxy with ruby on rails

alfredo1
Shopify Partner
2 0 0

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.

Replies 4 (4)

Matias_Fernande
Shopify Partner
7 0 6

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! 

OliUK
Shopify Partner
234 2 48

Thanks Matias!

devender-hiren
Shopify Partner
1 0 0

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

 

alfredo1
Shopify Partner
2 0 0

Thanks, Matias!  This was driving me nuts.