here is my problem, i get a variable from a request and store it in @response.
then i debug response, debug(@response), and get this output:
--- !ruby/hash:Hashie::Mash
results:
- !ruby/hash:Hashie::Mash
id: '33098557'
firstName: john
lastName: star
relationship: self
photo: https://foursquare.com/img/blank_boy.png
tips: !ruby/hash:Hashie::Mash
count: 0
lists: !ruby/hash:Hashie::Mash
groups:
- !ruby/hash:Hashie::Mash
type: created
count: 1
items: []
gender: male
homeCity: mexico
bio: ''
contact: !ruby/hash:Hashie::Mash
email: jhon@hotmail.com
unmatched: !ruby/hash:Hashie::Mash
email: []
i can get the results by typing @response.results, and get debuged this:
---
- !ruby/hash:Hashie::Mash
id: '33098557'
firstName: john
lastName: star
relationship: self
photo: https://foursquare.com/img/blank_boy.png
tips: !ruby/hash:Hashie::Mash
count: 0
lists: !ruby/hash:Hashie::Mash
groups:
- !ruby/hash:Hashie::Mash
type: created
count: 1
items: []
gender: male
homeCity: mexico
bio: ''
contact: !ruby/hash:Hashie::Mash
email: jhon@hotmail.com
but i cant get the inner attributes like the email or firstname, how can i access those attributes???
@responseis an instance ofHashie::Mash, while@response.resultsis an instance ofArray, so you need to access the index of the array you wish to receive a result for.will return the values for
firstNameandemailof the first result respectively. You can loop through the responses (to get all results if there happens to be more than one) withIf there’s always only one
resultyou can also access this with Ruby’s.firstmethod