【发布时间】:2019-03-29 09:27:38
【问题描述】:
我正在使用 Shopify、Ruby on Rails 和 Heroku postgres,但我不断收到此错误:
ActiveResource::ForbiddenAccess (Failed. Response code = 403. Response message = Forbidden.) and Completed 500 Internal Server Error in 210ms (ActiveRecord: 1.3ms)
我正在尝试将 Shopify 的数据 CRUD 到另一个来自 rails 的应用程序,我尝试迁移数据库和 heroku 日志以找出问题,但我没有找到。
这是我的控制器代码
def index
@products = ShopifyAPI::Product.find(:all, params: { limit: 10 })
@webhooks = ShopifyAPI::Webhook.find(:all)
end
def show
@products = ShopifyAPI::Product.find(params[:id])
end
def new
@products = ShopifyAPI::Product.new
end
def create
@products = ShopifyAPI::Product.new(params.require(:product).permit(:title))
if @products.save
redirect_to home_index
else
render :index
end
end
这是我的路线
Rails.application.routes.draw do
resources :home
post 'home/new', to: 'home#create'
end
我的 new.html.erd
<%= form_for :product do |f| %>
<p>
<%= f.label :name %>
<%= f.text_field :title %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
这是我的 index.html.erd
<% @products.each do |product| %>
<li><%= link_to product.title, "https://#{@shop_session.url}/admin/products/#{product.id}", target: "_top" %></li>
<%= link_to 'Create Product', new_home_path %>
<% end %>
【问题讨论】:
-
你有什么问题?
-
请分享您的错误屏幕截图以找出问题。
-
HTTP 500 是一般的服务器端错误消息。它本身几乎没有告诉我们任何事情。每当您看到这一点时,您的第一步应该是检查您的错误日志以获取更多详细信息。以
heroku logs开头。
标签: ruby-on-rails ruby heroku ruby-on-rails-5 shopify