Reputation: 8597
I've done PHP and was able to get JSON format to display nicely using
<pre></pre>
Now I'm trying to figure out how would you apply something similar with Ruby on Rails?
In my views document, I have this:
<%= @recent_media_items.to_json %>
Upvotes: 1
Views: 311
Reputation: 121
I recommend trying CodeRay gem. It will do all the work for you. Just send to it your JSON and you'll get nice, colorized output:
html = CodeRay.scan("{\"Hello\":\"world!\"}", :json).div
or in your case
<%= CodeRay.scan(@recent_media_items.to_json, :json).div %>
Upvotes: 1
Reputation: 29880
<pre><%= @recent_media_items.to_json %></pre>
? <pre>
is HTML, not PHP...
Upvotes: 5