我目前使用google_places gem來嘗試訪問場所API。我使用下面的代碼,得到的結果:未初始化的恆定GooglePlaces
class PlacesController < ApplicationController
def index
if params[:search]
@client = ::GooglePlaces::Client.new(Rails.application.secrets.places_api_key)
@places = @client.spots_by_query(params[:search])
end
end
end
我遇到的uninitialized constant GooglePlaces
一個錯誤,如果我不出去的範圍,其被替換爲PlacesController::GooglePlaces
。我相信這是一個範圍問題,但我沒有嘗試解決這個問題。我遵循repo自述文件中的說明,並假設我不必將源代碼包含在我的站點的lib目錄中。我可以從導軌控制檯正確使用寶石。
哇,我壓根沒想到要重新啓動服務器,因爲我通常不會有發展。這解決了這個問題。謝謝! – danielunderwood
在配置文件發生任何更改後,我們需要重新啓動服務器 – Shiva