2017-09-13 71 views
0

我正在使用google_api_client 0.10.3。我有這樣的電話:Google api客戶端calendarv3事件初始化參數錯誤

Google::Apis::CalendarV3::Event.new({ 
    'summary' => summary, 
    'description' => description, 
    'start' => event_datetime(check_out_time), 
    'end' => event_datetime(check_out_time), 
}) 

不知怎的,我得到這個錯誤:

ArgumentError: wrong number of arguments (given 1, expected 0) 
from .../gems/google-api-client-0.10.3/generated/google/apis/calendar_v3/classes.rb:964:in `initialize' 

這太令人費解,因爲事實上類定義帶有參數:

def initialize(**args) 

任何幫助?

回答

1

在符號中使用符號而不是字符串。

Google::Apis::CalendarV3::Event.new(
    summary: summary, 
    description: description, 
    start: event_datetime(check_out_time), 
    end: event_datetime(check_out_time), 
) 

在紅寶石,雙圖示符(**)是用於捕獲關鍵字參數 - 其中,通過設計,必須始終是符號。

+0

保存了我的一天。多謝! – EJ2015

相關問題