我目前正在做一个Ruby on Rails项目,尝试从Google Calendar API进行查询。我使用的是这行代码:
service = Google::Apis::CalendarV3::CalendarService.new我的Gemfile中有gem google-api-client。然而,当我尝试用这一行运行应用程序时,它失败了,因为它是未知常量: Google Apis。如果我尝试放入我在StackOverflow上看到的代码行,我将require 'google/apis/calendar_v3'放在ruby文件中,它会失败。我花了4个小时在网上试图找到任何有类似解决方案的人。如果我尝试另一个应用程序接口,比如require 'google/apis/drive_v2',它工作得很好,就是日历。:(
发布于 2016-11-02 23:30:17
下面的代码适用于我在Rails 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文件包含:
gem 'google-api-client', '0.9'https://stackoverflow.com/questions/40371927
复制相似问题