简体   繁体   English

Rails-查看看不见的评论

[英]Rails - View unseen comments

I have a Leads model which has comments. 我有一个带有评论的潜在顾客模型。 Stored in the comments model. 存储在注释模型中。

When users are browsing leads, I would like to show them how many new comments there are since the last time they viewed a particular lead's profile. 用户浏览潜在客户时,我想向他们展示自上次查看特定潜在客户的个人资料以来有多少新评论。

How would I go about this? 我将如何处理?

My initial idea is to store the last time a user browsed a lead's profile and the number of comments that come after this date would be the unread comments. 我最初的想法是存储用户上次浏览潜在客户的个人资料的时间,该日期之后出现的评论数将是未读评论。 Am I going in the right direction? 我朝着正确的方向前进吗?

  • add seen attribute/coulmn with default of 0 (ie not seen) to comments table with a migration. 将带有默认值0(即不可见)的seen属性/队列添加到带有迁移的注释表中。
  • permit seen if you are using strong parameters or make it attribute accessible. 如果您正在使用强参数或使其属性可访问,则允许seen
  • in leads model show only those comments if !comment.seen 在潜在顾客模型中, if !comment.seen仅显示那些评论
  • when a user visits the leads model update seen attribute of all comments to 1 (seen) 当用户访问潜在客户模型时,将所有评论的“看到的属性”都设为1(可见)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM