I'm sure it can be done in one query, but this is how I'd do it: combined = Array.new combined << Comment.all combined << Favorite.all # …etc. Though you'll want to set limits to the above
@feed = combined.sort { |x,y| y.created_at <=> x.created_at } …and then when looping through in your views, use "object.class.to_s" to see what it is, and change the icon, style, etc accordingly. I look forward to any other replies which have a better way of doing it, 'cause multiple queries isn't great, but a news feed can be cached very easily so I don't see much problem with the above! :) On Wed, Dec 24, 2008 at 3:47 PM, Dave Amos <rails-mailing-l...@andreas-s.net > wrote: > > I've tried googling for more information on this, but I've come up > empty. > > Has anyone implemented a facebook-style news feed on their rails app? > Here's my situation. I have a recipe-sharing site, and I'd like to have > a feed that shows a user when a few different actions happen to them or > their recipes (like adding as a favorite, adding as a follower, etc.). > > I don't know how to essentially take three or four queries and combine > them into one feed that I can display in my view chronologically. Is > there a plugin for this that I don't know about? > > Thanks for the help; any tips are helpful. > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---