Implementing a News Feed / Activity Feed on Several Models - Recommendations?

Hello, I'm interested in learning how to implement a News Feed /
Activity Feed on a web app for multiple models like Books, Authors,
Comments, etc...

Any recommendations from the group? Gems/Plugins, or experience
personally or from others on the best/smartest way to proceed?

Thanks!

http://railscasts.com/episodes/87-generating-rss-feeds

I did it by creating a new model called FeedItem and then creating an
observer to watch a certain subset of models and create feed items
when they were created, updated, and deleted. FeedItems have a
polymorphic association to the model being talked about and a user
association for who is doing the action, and then a string field
denoting the action taken on them ("created" or "destroyed" for
example).

Then on each model I created a #best_identifier method which allows
the model to specify how it should be identified to the user in the
feed and elsewhere in the app. So for the feed itself, I just render
the last 30 feed items with "#{feed_item.user_id}
#{feed_item.action_name} #{feed_item.modified_model.best_identifier}
on #{feed_item.created_at.to_s(:short)}".

Hopefully this helps! I can pastie my exact code if you'd like. There
are some other small tidbits to add like checking for destroyed models
(because you can't call best identifer on them anymore), linking to
the model and perhaps user, adding images where appropriate, ...

Nice solution!

Another possibility would be to use the before_create and delete
methods.

Or just have the new controller pull the latest info from your other
models by looking at the updated_at field. This way you wouldn't have
to have an extra step when deleting items.

@hornairs that's very interesting. I love the idea of an observer to
watch model CRUD actions, I have not heard of such a thing before.
Could you show that with pastie, that seems like an elegant way to
implement versus after_create... across multiple models.

The FeedItems model sounds like it requires a lot of JOINs which is
something I want to avoid. I'd like to have everything the feed
rendering partial needs in the feedItem record for performance
reasons. I've seen on StackOverflow an example of doing something like
id, model_name, model_type, data {commentID: asdadasd, content:
"asdasdad"}

What do you think of that? I'm not sure yet how to user a hash that's
stored like that in a column, if you know of any pointers on where I
could learn such a thing that'd be great.

Thank you