Ruby On Rails RSS Reader

July 12, 2008 – tagged as rails, rss, ruby

We moved our Athlo blog to a WordPress app to separate it completely from the main app. One interaction I wanted between the two though was for the most recent blog entries to show on the Athlo site. I thought that RSS would offer an easy solution so I started looking around to find out if I’d need a Rails plugin or something like that.

The solution was far simpler. And pure Ruby (man I love this language!).

require 'rss'
rss = RSS::Parser.parse(open('').read, false).items[0..MaxRSSItems-1]

That’s it. That simple call supplies you with a full array of all the items from the RSS feed. In my specific example, I’ve used a range to limit the results to the value of MaxRSSItems.

No plugins required. No Rails required. Ruby RSS will do what you need to read feeds. (That should be in a poem.)


This article is 10 years old and closed for new comments.

Steve • April 8, 2009

It should be a poem. Thanks for the information!

Bill Leeper • December 7, 2010

This is what I love about Ruby, simple clean answer.