I’d like to install a scripttag for shopify with a Rails App.
My js file is here: http://javascript.dataglobe.eu/index.js, it has only one sayHello() function.
I made the authentication in my Rails app, I get the token, and I added two lines to install a scripttag:
ShopifyAPI::Base.site = @token
s = ShopifyAPI::ScriptTag.create(:event => "onload",:src => "http://javascript.dataglobe.eu/index.js")
My app is deployed to heroku, and after installing it, I always get this error:
URI::BadURIError (both URI are relative):
app/controllers/home_controller.rb:19:in `index’
Where is my mistake?
It doesn’t look like you’re following the instructions for the gem, namely this part:
Use that token to instantiate a session that is ready to make calls to the given shop.
token = params[:access_token]
session = ShopifyAPI::Session.new(“yourshopname.myshopify.com”, token)
session.valid? # returns true
6.Now you can activate the session and you’re set:
From the docs for the gem here: https://github.com/Shopify/shopify_api
A good way to verify things are working is by request ion some data, such as products or orders and see if the request completes.