Opps sorry, obviously you can't add each result to an array and sort them, you'd have to merge the resulting arrays! ;)
On Wed, Dec 24, 2008 at 4:15 PM, Ashley Williams < [email protected]> wrote: > 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 < > [email protected]> 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

