I'm trying to display json in a view that I've put in this variable '@yearbook':
def list
file = File.open("#{Rails.root}/lib/service.json", "r")
service = file
service = service.read
service = JSON.parse(service)
@yearbook = service
end
In my view file, I go through every '@yearbook' element and simply display it like so:
<% @yearbook.each do |item| %>
<tr>
<p><%= item %></p>
</tr>
And this is what I get from the view on my browser (which is normal):
{"name"=>"...", "description"=>"..."}
{"name"=>"...", "description"=>"..."}
...
Now I don't understand how I can specify to the view to display me the "name" and "description" attributes instead of the formatted json object, making it look more like this:
name: ..., description: ...
name: ..., description: ... and so on...
Hope it's clear, cheers.