I am trying to convert the Ruby array of hashes to a JSON and return it.
What I've tried so far:
hash ={}
user.attributes.each_pair do |key, value|
if(key == 'auth_id')
hash[key] = value
elsif (key == 'useractivity')
# How do I get to the Key's array of useractivities from here?
# {useractivities : [{id:,:name},{:id,:name}]}
end
end
return hash.to_json
Thanks!
hash[key] = value[:useractivities]?