2016-11-02 3 views
0

현재 Google 캘린더 API에서 쿼리를 시도하는 Ruby on Rails 프로젝트를 진행하고 있습니다. 나는이 코드 라인을 사용하고 있습니다 :Ruby on Rails Google API

service = Google::Apis::CalendarV3::CalendarService.new 

을하고 내 Gemfile에 보석 google-api-client 있습니다. 그러나이 줄을 사용하여 응용 프로그램을 실행하려고하면 Unknown Constant : Google Apis라는 메시지가 표시되지 않습니다. 내가 StackOverflow에서 본 라인에 넣으려고하면, 어디에 require 'google/apis/calendar_v3' 루비 파일에 넣어, 실패합니다. 비슷한 솔루션을 가진 사람을 찾기 위해 온라인으로 4 시간을 보냈습니다. require 'google/apis/drive_v2'과 같은 다른 API를 사용하면 캘린더 만 제대로 작동합니다. :(

+0

이 사이트에서 참조를 복용하십시오. 그것은 나를 위해 일했습니다. http://www.thegreatcodeadventure.com/using-the-google-api-ruby-client-with-google-calendar-api/ –

+0

정확한 오류 메시지를 포함하도록 질문을 편집 할 수 있습니까? 하나는 "Unknown Constant"이고, 하나는'require'를 사용하는 것이 실패하는 것입니다. – RJHunter

답변

1

레일 4.2.1에 나를 위해 작품 뒤의 - 두 필요가 있습니다

require 'google/apis' 
=> true 
require 'google/apis/calendar_v3' 
=> true 
service = Google::Apis::CalendarV3::CalendarService.new 
=> #<Google::Apis::CalendarV3::CalendarService:0x007fca01ae60a0 @root_url="https://www.googleapis.com/", @base_path="calendar/v3/", @upload_path="upload/calendar/v3/", @batch_path="batch", @client_options=#<struct Google::Apis::ClientOptions application_name="unknown", application_version="0.0.0", proxy_url=nil, use_net_http=false>, @request_options=#<struct Google::Apis::RequestOptions authorization=nil, retries=0, header=nil, timeout_sec=nil, open_timeout_sec=20>> 

내 보석 파일이 포함되어

gem 'google-api-client', '0.9'