Rails的刷新页面对于所有用户命令 [英] Rails Refresh Page For All Users On Command

查看:116
本文介绍了Rails的刷新页面对于所有用户命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望创建一个将用作计划,概述了我的地方教会服务/事件的运行秩序的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:

  1. Meteor.js
  2. Node.js的
  1. Meteor.js
  2. 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:

  1. 在AJAX投票
  2. AJAX长轮询
  3. 的WebSockets
  4. 服务器端事件

查阅有关这些方法有很大的话题:<一href="http://stackoverflow.com/questions/11077857/what-are-long-polling-websockets-server-sent-events-sse-and-comet">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:

  1. <一个href="http://edgeguides.rubyonrails.org/action_controller_overview.html#live-streaming-of-arbitrary-data"相对=nofollow>动作控制器概述:任意数据
  2. 的ActionController ::直播截屏
  3. 样动作控制器的实现直播
  1. Action Controller Overview: Live Streaming of Arbitrary Data
  2. ActionController::Live screencast
  3. Sample Implementation of Action Controller Live

这篇关于Rails的刷新页面对于所有用户命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆