简体   繁体   English

Shopify脚本标签安装 - > URI :: BadURIError

[英]Shopify scripttag install -> URI::BadURIError

I'd like to install a scripttag for shopify with a Rails App. 我想使用Rails应用程序为shopify安装脚本标签。 My js file is here: http://javascript.dataglobe.eu/index.js , it has only one sayHello() function. 我的js文件在这里: http//javascript.dataglobe.eu/index.js ,它只有一个sayHello()函数。 I made the authentication in my Rails app, I get the token, and I added two lines to install a scripttag: 我在我的Rails应用程序中进行了身份验证,我获得了令牌,并添加了两行来安装脚本标签:

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' 我的应用程序已部署到heroku,安装后,我总是收到此错误:URI :: BadURIError(两个URI都是相对的):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: 它看起来不像你按照宝石的说明,即这部分:

  1. 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? token = params [:access_token] session = ShopifyAPI :: Session.new(“yourshopname.myshopify.com”,token)session.valid? # returns true #返回true

6.Now you can activate the session and you're set: 6.现在您可以激活会话并设置:

ShopifyAPI::Base.activate_session(session)

From the docs for the gem here: https://github.com/Shopify/shopify_api 来自宝石的文档: 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. 验证工作正常的一种好方法是通过请求离开一些数据,例如产品或订单,并查看请求是否完成。

Sorry for bringing up an old post. 很抱歉打开一个旧帖子。 But I found that if I put in my controller: 但我发现如果我放入我的控制器:

around_filter :shopify_session

It fixed many things for me. 它为我修复了很多东西。 I was using the Shopify App they provided. 我正在使用他们提供的Shopify应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM