ruby on rails - Httparty get information to use inside view -


so have @ moment.

api = httparty.get("api url here").parsed_response @api = api["events"] 

this returning this.

[{"id"=>1015765, "date"=>"/date(1468062000000+0100)/", "venuename"=>"milton keynes bowl", "town"=>"milton keynes", "country"=>"uk", "layoutid"=>3932, "eventgroupid"=>32347, "venueid"=>3596}] 

now how go getting venuename view?

i've tried putting <%= @api.id %> didn't work

i wondering if it'd better venue name in controller can used elsewhere?

thanks sam

since @api array of hashes, can in view:

<% @api.each |event| %>   <%= event['venuename'] %> <% end %> 

for each of events in array, output venuename element hash.

to first event's name in controller:

@name = @api.first['venuename'] 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -