2012-08-10 13 views
2

我正在嘗試使用https://github.com/tapajos/highrise/在用戶註冊到應用程序時更新用戶帳戶。不過,我並沒有走得太遠。如何添加使用高層Ruby寶石的人?

在控制檯我做:

person = Highrise::Person.create(:name => "charlie") 

既節約了罰款,但如果我這樣做

person = Highrise::Person.create(:name => "charlie", :email => "[email protected]") 

然後我得到:

Unprocessable Entity 

我不能讓我的頭繞這個,我基本上想添加一個完整的記錄:

person = Highrise::Person.create(:name => "charlie", :params => {:contact_data => {:email_addresses => "[email protected]"}}) 

但我仍然得到同樣的錯誤,不能在網上找到

回答

6

你在正確的軌道與去年嘗試的任何實例。試試看:

person = Highrise::Person.create(
    :first_name => "Charlie", :last_name => "Bravo", 
    :contact_data => { 
     :email_addresses => [{ 
     :email_address => {:address => "[email protected]"} 
     }] 
    } 
) 

這與在Highrise API中定義的創建人員請求的結構相匹配。 https://github.com/37signals/highrise-api/blob/master/sections/people.md#create-person

另外你可以參考ruby api的測試規範瞭解更多示例https://github.com/tapajos/highrise/blob/f44cb3212c6d49549330c46454fe440ac117fa1b/spec/highrise/person_spec.rb#L40