Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Advanced Social Features in Ruby on Rails Activity Feeds Displaying Activity

Avoid duplicated results

What is the best way to not show duplicated results? So if I track an user follow activity and someone follows, unfollow and then again follows and user the activity only shows up ones.

Brandon Barrette
Brandon Barrette
20,485 Points

Could you clarify your question? You want duplicate results or you do not? I'm not sure I understand.

1 Answer

So I figured it out in the meantime. I had to destroy the activity when I delete an association (for example with an unfollow), I think this should also be covered in the tutorial.

J Scott Erickson
J Scott Erickson
11,883 Points

IMO destroying the activity is counter to the idea of keeping all of the actions that occur. Your fix of removing the record 'works', but does create a data integrity issue. Not that you would be worried about that on a tutorial. But IMO I would probably write a helper method that filters out actions of the same type within a certain timeframe.