views:

162

answers:

3

My rails app has couple of content generating resources like Article, Blog Posts, etc..

I can generate the RSS for each individual resource but I'm not getting how to synchronize into one RSS feed for these multiple feeds.

Currently I've setup the Articles feed via FeedBurner and even FeedBurner doesn't have this facility to merge different RSS of the same app into one so that I users can subscribe to individual RSS (Which I've done already) or to just a single main feed to get all the updates.

I can't find any plugins nor found any code googling around for my Rails app??

+1  A: 

FeedStitch allows you to "stitch" multiple feeds together. It doesn't solve it from the Rails point of view, but it gets the job done.

I recommend putting your feeds into feedstitch, and then use feedburner with the feedstitch feed.

Sam Nardoni
+1  A: 

If you want to solve the problem from the Rails side, it's not so complicated. Create a new action and fetch the records you want to format as a feed and create the feed.

# the action
def feed
  @articles = Article.all(:limit => 10)
  @posts = Post.all(:limit => 10)
  @items = @article + @posts

  respond_to do |format|
    format.html
    format.atom
  end
end

# the view
atom_feed do |feed|
  feed.title("Latest items")
  feed.updated(@items.first.try(:created_at))

  for item in @items
    feed.entry(item) do |entry|
      entry.title(item.title)
      entry.content(item.body, :type => 'html')
    end
  end
end

Off course, the resources must share the same API at least for the methods you want to call in the controller. http://api.rubyonrails.org/classes/ActionView/Helpers/AtomFeedHelper.html#M001900

Simone Carletti
A: 

In case you accept to rely on an external service for that, you can use RSS Mix or Yahoo! Pipes:

www.rssmix.com/

pipes.yahoo.com/pipes/

Florent2