2013-02-27 62 views
1

我正在使用名爲Desk的寶石從desk.com的API返回數據。當我運行Desk.customers(:custom_external_id => temp.id)時,它返回一組可愛的數據。軌道提取變量從怪傑返回的hashie

我在尋找id=71095620的整數71095620。

=> #<Hashie::Rash count=20 page=1 results=[#<Hashie::Rash customer=#<Hashie::Rash addresses=[] custom_external_id="58749" emails=[#<Hashie::Rash email=#<Hashie::Rash created_at="2013-02-13T15:59:26-08:00" email="CENSORED" i 
d=33622514 updated_at="2013-02-13T15:59:26-08:00" verified_at=nil>>] first_name="CENSORED" id=68712186 language=nil last_name="CENSORED" phones=[#<Hashie::Rash phone=#<Hashie::Rash created_at="2013-02-13T16:00:45-08:00" id=1301079 phone="CENSORED" updated_at="2013-02-13T16:00:45-08:00">>] twitters=[nil]>>, #<Hashie::Rash customer=#<Hashie::Rash addresses=[] custom_external_id="58749" emails=[] first_name="CENSORED" id=71095620 language=nil last_name="CENSORED" phones=[] twitters=[nil]>>] total=2> 

顯然存在多個id字段,我不知道哪種方式最好提取該整數。提前致謝!

回答

2

按照Hasie::Rash readme,你也許可以做到這一點

response = Desk.customers(:custom_external_id => temp.id) 
response.results[1].customer.id