Rails的刷新页面对于所有用户命令命令、页面、用户、Rails

2023-09-10 22:19:10 作者:生来倔强

我希望创建一个将用作计划,概述了我的地方教会服务/事件的运行秩序的Rails应用程序。其基本概念是技术团队谁控制音响,灯光,视觉效果等,并志愿者可以登录到该应用程序并查看运行秩序将含有包括时序等方面的服务的所有元素。

I'm looking to create a Rails application that will be used as programme that outlines the running order of a service / event for my local church. The basic concept is that the technical team who control the sound, lighting, visuals etc and the volunteers can log in to the application and view the running order which will contain all the elements of the service including timings etc.

我想制片人是能够控制的运行秩序,让他/她基本上是一个下一步/返回按钮,可以循环演出的每个元素。这样的球队都知道什么阶段,他们都在服务,他们需要做的事情。什么

I want a producer to be able to control the running order, so that he / she has basically a 'Next' / 'Back' button and can cycle through each element of the show. This way the team all know exactly what stage of the service they are on and what they need to do.

我的问题:我怎样才能让这个当制片presses下一步按钮,应用程序刷新/更新所有用户和他们所看到的最新的元素?每个人都必须观看同样的信息 - 并迅速太多

My question: How can I make it so that when the producer presses the 'Next' button, the application refreshes / updates for all users and they see the latest element? Everyone needs to be viewing the same information - and quickly too.

任何帮助AP preciated!

Any help appreciated!

感谢

推荐答案

好了,你已经分配的jQuery AJAX 标记你的问题,所以我想你明白Rails的只是一个后端解决方案,并不能处理客户端的更新本身(的至少,之前到Rails 4 的)。如果你的任务就是这样简单,你描述的依赖,许多即时更新所有的用户,我会建议切换到一些JavaScript平台,因为他们发明了这样的任务。最流行的是:

Well, you have assigned jquery and ajax tags to your question, so I assume you understand that Rails is just a backend solution and can not handle the client-side updates itself (at least, prior to Rails 4). In case your task is just that simple as you described and relies that much on instant updates for all users, I would recommend switching to some javascript platform as they were invented for this kind of task. The most popular are:

Meteor.js Node.js的 Meteor.js Node.js

然而,同样的事情,仍然可以使用Rails后端完成。在这里,你也有很多方法来挑选:

Nevertheless, the same thing can still be done with rails backend. Here you've also got plenty of approaches to pick from:

在AJAX投票 AJAX长轮询 的WebSockets 服务器端事件

查阅有关这些方法有很大的话题:What是长轮询,的WebSockets,服务器发送的事件(SSE)和彗星?。实现的例子很容易被发现在网上也。

Check out a great topic about each of these methods: What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?. The examples of implementations are easily found over the web as well.

大多数这些方法需要一些客户端的编码,但它的量可以减少与轨道4的一个新功能:使用服务器端事件的ActionController ::直播的ActionController ::流。下列资源可能会有所帮助:

Most of these ways would require some client-side coding, however, the amount of it could be reduced with a new feature of Rails 4: Server-Side events using ActionController::Live and ActionController::Streaming. The following resources may be helpful:

动作控制器概述:任意数据 的ActionController ::直播截屏 样动作控制器的实现直播 Action Controller Overview: Live Streaming of Arbitrary Data ActionController::Live screencast Sample Implementation of Action Controller Live