1
votes

I'm developing a new Shopify App. It's already installed. I'm developing on Shopify API 7.2.0 and Ruby 5.

So I'm trying to attach a javascript file on frontpage.

That's my code on app > controllers > home_controller.rb

class HomeController ... ShopifyApp::AuthenticatedController
  def index
    ss = ShopifyAPI::ScriptTag.create({:src => "https://.../script.js", :event => 'onload'})
  end
  def script
    ss = ShopifyAPI::ScriptTag.create({:src => "https://.../script.js", :event => 'onload'})
  end
end

That's the only way I found to work.

If I include just one ss = ShopifyAPI::ScriptTag.create({:src => "https://.../script.js", :event => 'onload'}) it does not attach.

What am I doing wrong? I didn't find documentation about it.

1

1 Answers

1
votes

Looks like you did not follow the steps described in the gem

https://github.com/Shopify/shopify_api

I assume you did not set up a session so you cant "connect" to your store.
Verify that you have a valide session and it will work

enter image description here