I’m using the RapLeaf API in a Rails app and when I call a RapLeaf record I get a response in JSON. How can I display JSON data using a Ruby method?
Here is the controller:
@user = User.find_by_id(params[:id])
@api = RapleafApi::Api.new('<MY_SECRET_API_KEY>')
Here is the view:
%td
= @api.query_by_email(@user.email)
Here is what it looks like when rendered in the page:
{“gender”=>”Male”}
I want to be able to call the gender this way
%td
= @api.query_by_email(@user.email).gender
But I get an undefined method `gender’ for {“gender”=>”Male”}:Hash
What sort of method do I need to create to call gender using .gender?
Turns out that output data is a Ruby hash and not JSON. I’ve got to get my terminology strait.