我正在构建一个与 Highrise 集成的应用程序,并且到目前为止非常好,但是,当尝试导入一个人时Highrise::People
,它会吐出一个类似于这样的巨大哈希:
[ ..., #<Highrise::Person:0x1035084b8 @attributes={"contact_data"=>#<Highrise::Person::ContactData:0x1034f8b30 @attributes={"email_addresses"=>[], "addresses"=>[], "web_addresses"=>[], "phone_numbers"=>[], "twitter_accounts"=>[], "instant_messengers"=>[]}, @prefix_options={}>, "created_at"=>Sat Nov 28 05:38:26 UTC 2009, "title"=>"president", "updated_at"=>Sat Nov 28 05:38:27 UTC 2009, "background"=>"asdfasdfadsfas", "id"=>27569370, "owner_id"=>nil, "group_id"=>nil, "company_id"=>27569371, "last_name"=>"Doe", "author_id"=>192208, "visible_to"=>"Everyone", "first_name"=>"John"}, @prefix_options={}>, ... ]
看起来每个内部Highrise::Person
都是一个@attributes
which is another Highrise::Person::ContactData
,它本身就是另一个@attributes
带有数组的email_addresses[]
和phone_numbers[]
以及简单的键/值......
很抱歉让您感到困惑,我想知道的是如何first_name
从这样的哈希中获取每个人的
可能超级简单我只是感到困惑......
更新
我想一个更好的表达方式是,鉴于上面的哈希,为什么这不起作用:
@people = Highrise::Person.find(:all)
for person in @people do
person.attributes["first_name"]
end