I finished Ruby on Rails tutorial where I can follow other users and others may follow me like twitter. Now I wonder how to implement notification system if someone starts to follow me, for example, as in stackexchange or facebook in which come and display a notification (eg red 1). How to go about it? Are there any examples of ready solutions you or MVC?
我完成了Ruby on Rails教程,在那里我可以跟踪其他用户,其他人也可以像twitter一样跟踪我。现在我想知道,如果有人开始跟踪我,比如在stackexchange或facebook上,如何实现通知系统(如红色1)。你和MVC有现成的解决方案吗?
2 个解决方案
#1
5
I'd add a before_filter
to relevant controller actions that checks for new followers in the database and sets flash[:notice]
to something useful like 'X new followers' and links to your followers page. There's a quick overview of how flash works in the docs: http://api.rubyonrails.org/classes/ActionDispatch/Flash.html
我将在相关的控制器动作中添加一个before_filter,它检查数据库中的新关注者,并将flash[:notice]设置为一些有用的东西,比如“X新关注者”和到您的关注者页面的链接。有一个关于flash如何在文档中工作的简要概述:http://api.rubyonrails.org/classes/ActionDispatch/Flash.html。
#2
1
Have a look at those 2 railscasts:
看看那两辆火车:
- http://railscasts.com/episodes/407-activity-feed-from-scratch
- http://railscasts.com/episodes/407-activity-feed-from-scratch
- http://railscasts.com/episodes/406-public-activity.
- http://railscasts.com/episodes/406-public-activity。
#1
5
I'd add a before_filter
to relevant controller actions that checks for new followers in the database and sets flash[:notice]
to something useful like 'X new followers' and links to your followers page. There's a quick overview of how flash works in the docs: http://api.rubyonrails.org/classes/ActionDispatch/Flash.html
我将在相关的控制器动作中添加一个before_filter,它检查数据库中的新关注者,并将flash[:notice]设置为一些有用的东西,比如“X新关注者”和到您的关注者页面的链接。有一个关于flash如何在文档中工作的简要概述:http://api.rubyonrails.org/classes/ActionDispatch/Flash.html。
#2
1
Have a look at those 2 railscasts:
看看那两辆火车:
- http://railscasts.com/episodes/407-activity-feed-from-scratch
- http://railscasts.com/episodes/407-activity-feed-from-scratch
- http://railscasts.com/episodes/406-public-activity.
- http://railscasts.com/episodes/406-public-activity。