大家好,
我遇到了一个我自己无法弄清楚的问题,它相信所有的专业知识都可以帮助我解决每当我尝试访问添加脚本的路径时遇到的错误。这是我的控制器代码:
class HomeController < AuthenticatedController
def index
@products = ShopifyAPI::Product.find(:all, :params => {:product_type => "Underarmour"})
# script = ShopifyAPI::ScriptTag.new(:all, :params => {:event => "onload", :src => "https://shopperapproved.herokuapp.com/sajs/14043.js"})
end
def script
ShopifyAPI::ScriptTag.create(:event => "onload", :src => "https://shopperapproved.herokuapp.com/sajs/14043.js")
end
end
我的路线文件是:
controller :sessions do
get 'login' => :new, :as => :login
post 'login' => :create, :as => :authenticate
get 'auth/shopify/callback' => :callback
get 'logout' => :destroy, :as => :logout
end
root :to => 'home#index'
match "script/",
:to => "home#script",
:via => :get
我想通过访问此路线来添加脚本:在我的索引视图中:
<h3>Add your ShopperApproved site ID:</h3> https://shopperapproved.herokuapp.com/script --> if i am going to click this link i will be redirected to HomeController#script
我希望你能帮帮我..
答案 0 :(得分:0)
你有没有设置一个视频和令牌?我不能在你的商店中创建脚本
https://github.com/Shopify/shopify_api
我假设您没有设置会话,因此您无法连接&#34;到你的商店。
验证您是否有valide会话并且它将起作用