How do i style a JSON feed in my view?
- by stephenmurdoch
My rails app gets the following JSON feed from mixcloud and sticks the results into my index page
At the moment when I do this, the entire contents of my feed are displayed unformatted in one big blob of scary looking text (without the curly JSON brackets)
I only want to display specific values from the feed in the view.
From the feed in question lets say for simplicity that I just wanted to display all values with a key of "url"
In case I'm doing something wrong here's my code:
# podcast controller
def index
# I'm using a class method to get the feed
@feed = Podcast.feed
end
# podcast model
def self.feed
feed = JSON.parse(open("http://api.mixcloud.com/alivefrommaryhill/feed").read)
end
# index.html.haml
.feed
= @feed
I can't figure out how to style the results and display only certain items from the feed. Is my approach wrong?