Reputation: 110950
I'm using the Koala gem to access the facebook graph api.
When I make a call I get back:
<%= @fb.inspect %>
Output:
[{"name"=>"Bob Jones", "id"=>"13223123112323"}]
How do I access name?
@fb.id works for id but
@fb.name does not work?
Error:
undefined method `name' for [{.....
Ideas? Thanks
Upvotes: 0
Views: 257
Reputation: 5079
It is an array of Hash objects.
@fb.first["name"]
You must get the first (in this case only) object for the array, and then get the value for the "name" key out from it.
Upvotes: 1