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.

On Sep 28, 11:03 am, hornairs <harry.brund...@gmail.com> wrote:
> 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, ...
>
> On Sep 27, 11:14 pm, nobosh <bhellm...@gmail.com> wrote:
>
>
>
>
>
>
>
> > 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!

-- 
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-t...@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.

Reply via email to