Google api 从google地理编码api回滚事务错误轨道
我正在尝试在rails应用程序中创建审阅表单,但当我单击“提交”按钮时,表单无法提交。当我在终端中查找错误时,我收到此错误。我搜索了错误,但找不到任何解决方案。以前有人有过这个问题吗Google api 从google地理编码api回滚事务错误轨道,google-api,google-geocoding-api,Google Api,Google Geocoding Api,我正在尝试在rails应用程序中创建审阅表单,但当我单击“提交”按钮时,表单无法提交。当我在终端中查找错误时,我收到此错误。我搜索了错误,但找不到任何解决方案。以前有人有过这个问题吗 Google API error: over query limit. (0.1ms) rollback transaction 更新 create_table "reviews", force: :cascade do |t| t.string "title" t.text "bod
Google API error: over query limit.
(0.1ms) rollback transaction
更新
create_table "reviews", force: :cascade do |t|
t.string "title"
t.text "body"
t.integer "score"
t.string "restaurant"
t.integer "price"
t.string "cuisine"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "phone_number"
t.string "ambiance"
t.text "address"
t.float "latitude"
t.float "longitude"
t.integer "user_id"
end
我不仅得到了谷歌API的错误。有时我会遇到这个错误,而另一次我只会遇到回滚事务
这是审查管理员:
class ReviewsController < ApplicationController
# check if logged in
before_action :check_login, except: [:index, :show]
def index
# this is our list page for our reviews
@price = params[:price]
@cuisine = params[:cuisine]
@location = params[:location]
# start with all the reviews
@reviews = Review.all
# filtering by price
if @price.present?
@reviews = @reviews.where(price: @price)
end
# filter by cuisine
if @cuisine.present?
@reviews = @reviews.where(cuisine: @cuisine)
end
# search near the location
if @location.present?
@reviews = @reviews.near(@location)
end
end
def new
# the form for adding a new review
@review = Review.new
end
def create
# take info from the form and add it to the model
@review = Review.new(form_params)
# and then associate it with a user
@review.user = @current_user
# we want to check if the model can be saved
# if it is, we're go the home page again
# if it isn't, show the new form
if @review.save
flash[:succces] = "Your review was posted!"
redirect_to root_path
else
# show the view for new.html.erb
render "new"
end
end
def show
# individual review page
@review = Review.find(params[:id])
end
def destroy
# find the individual review
@review = Review.find(params[:id])
# destroy if they have access
if @review.user == @current_user
@review.destroy
end
# redirect to the home page
redirect_to root_path
end
def edit
# find the individual review (to edit)
@review = Review.find(params[:id])
if @review.user != @current_user
redirect_to root_path
elsif @review.created_at < 4.hours.ago
redirect_to review_path(@review)
end
end
def update
# find the individual review
@review = Review.find(params[:id])
if @review.user != @current_user
redirect_to root_path
else
# update with the new info from the form
if @review.update(form_params)
# redirect somewhere new
redirect_to review_path(@review)
else
render "edit"
end
end
end
def form_params
params.require(:review).permit(:title, :restaurant, :body, :score,
:ambiance, :cuisine, :price, :address)
end
end
<%= simple_form_for @review do |f| %>
<%= f.input :title %>
<%= f.input :restaurant %>
<%= f.input :address %>
<%= f.input :body %>
<%= f.input :cuisine %>
<%= f.input :price %>
<%= f.input :score %>
<%= f.input :ambiance %>
<%= f.button :submit %>
<% end %>
您可能已经达到了您的GoogleAPI配额 在模型中,您使用了
gem geocoder所使用的geocoded\u…
,所以请看一看
谷歌有每秒限制和每天限制。你有两个问题:
您正在使用Google的地理编码API配额,错误消息“超过查询限制”就是证明
最有可能的原因是,您的模型无法保存,而被回滚。地理编码API调用失败,无法保存
我会检查GoogleAPI控制台,看看你是否真的达到了他们的配额(如果你正在运行多个测试,并且你在他们的免费服务层上,这是可能的)。如果您还没有达到限制,请使用Google API提交支持请求。是的,但我甚至没有收到10条评论。我不认为我超出了限制。
create_table "reviews", force: :cascade do |t|
t.string "title"
t.text "body"
t.integer "score"
t.string "restaurant"
t.integer "price"
t.string "cuisine"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "phone_number"
t.string "ambiance"
t.text "address"
t.float "latitude"
t.float "longitude"
t.integer "user_id"
end