3

What approaches are there to implement comments on feed activities with GetStream using Ruby on Rails?

Are there any plugins for that, 3rd party, etc.? A Google search doesn't yield any results.

I am using the Stream-rails library.

Update [19th December, 2015]

I figured that I could create an ActivityComment model, and give it an activity_id property, and make use of the id property on each StreamRails::Activity you give me. However, it would be more convenient if I could persist Activity in my database, too, so I can later get comments by activity.

Kenny Meyer
  • 7,849
  • 6
  • 45
  • 66

1 Answers1

2

If you use stream-rails and use the Activity mixin for all your model classes, you always have a copy of all activities stored in your database. In your case you can retrieve all comments related to one activity if you keep a reference to it. The best way to store that reference is not activity_id but foreign_id.

One way to do this is the following: add a field in your ActivityComment and call it parent_foreign_id. Assign to that field the foreign_id of the commented activity.

When you want to retrieve all comments for one activity, you only need to fetch all ActivityComment models that have parent_foreign_id equal to the activity foreign_id.

Tommaso Barbugli
  • 11,781
  • 2
  • 42
  • 41