在我的申请中,我想在评论或帖子中提及他/她时通知用户.
用户句柄@user_name类似于Facebook.
提及的数据库表如下所示:
Mention
mentioned_by: user_id (foreign key)
user_mentioned: user_id (foreign key)
comment_id: (foreign key)
post_id: (foreign key)
Run Code Online (Sandbox Code Playgroud)
我无法想出实现它的方法.Facebook/Twitter如何做到这一点?
我决定使用的是使用ActiveRecord callbacks/ Observer design pattern,每当新的评论/帖子保存到数据库时,我都可以浏览帖子/评论的内容,并留意任何提及,然后根据需要执行通知.
我觉得有一些缺失的东西,我没有把它弄好.
这是最好的方式吗?
twitter notifications facebook ruby-on-rails observer-pattern