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
Post a Comment