简体   繁体   English

Ruby on rails facebook 就像没有页面刷新的通知

[英]Ruby on rails facebook like notification without page refresh

I am into a process of developing the facebook or stackoverflow like notification in my rails app.我正在开发 facebook 或 stackoverflow 之类的 Rails 应用程序中的通知。 when the new activity gets stored in the database i get the new notification flashed on the browser.当新活动存储在数据库中时,我会在浏览器上看到新的通知。 without refreshing the page.无需刷新页面。 there is a way by giving ajax request with the setInterval .有一种方法可以通过 setInterval 提供 ajax 请求。 but that looks so dull as there will be many requests on the server , i just want to flash notification on the homepage only when it gets stored in the database但这看起来很乏味,因为服务器上会有很多请求,我只想在主页上显示通知,只有当它存储在数据库中时

How can i achieve this ?我怎样才能做到这一点?

Unfortunately there is no "take this code and be happy" solution for your problem, since what you are asking for are websockets and rails 4 doesn't support them out of the box (rails 5 does with the new "action_cable").不幸的是,您的问题没有“使用此代码并感到高兴”的解决方案,因为您要求的是 websockets,而 rails 4 不支持开箱即用(rails 5 支持新的“action_cable”)。

You might want to have a look at these links:你可能想看看这些链接:

pusher web sockets推网络套接字

websockets rails gem websockets导轨宝石

pusher gem tutorial 推动宝石教程

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

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