2

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.

4

1 回答 1

1

如果您使用 stream-rails 并为所有模型类使用 Activity mixin,那么您始终拥有存储在数据库中的所有活动的副本。在您的情况下,如果您保留对某项活动的引用,则可以检索与一项活动相关的所有评论。存储该引用的最佳方式不是activity_idbut foreign_id

执行此操作的一种方法如下:在您的字段中添加一个字段ActivityComment并调用它parent_foreign_id。将注释活动的 分配给该字段foreign_id

当您想检索一个活动的所有评论时,您只需要获取与该活动相等的所有ActivityComment模型。parent_foreign_idforeign_id

于 2015-12-21T08:24:06.487 回答