# Server detects change in data

**URL:** <https://www.ruby-forum.com/t/server-detects-change-in-data/188205>\
**Category:** Rails\
**Created:** [May 7, 2010, 4:31pm UTC](https://www.ruby-forum.com/t/server-detects-change-in-data/188205 "2010-05-07T16:31:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [May 7, 2010, 4:31pm UTC](https://www.ruby-forum.com/t/server-detects-change-in-data/188205/1 "2010-05-07T16:31:01Z")

</div>

My fundamental lack understanding of Rails and the architecture of the  
'Net wil be demonstrated by the following question:

The following is a contrived example:

Assume I have several users looking at (identical) screens. Say, there  
is some slowly changing stock market data that they are all looking at.  
The price of the stock changes, say, once every minute.

Assume that a Rails application detects a change to the price and wants  
to push the change out to the users without the users needing to do  
anything? How does one make that happen?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [May 7, 2010, 4:35pm UTC](https://www.ruby-forum.com/t/server-detects-change-in-data/188205/2 "2010-05-07T16:35:36Z")

</div>

Ralph S. wrote:

> My fundamental lack understanding of Rails and the architecture of the  
> 'Net wil be demonstrated by the following question:
> 
> The following is a contrived example:
> 
> Assume I have several users looking at (identical) screens. Say, there  
> is some slowly changing stock market data that they are all looking at.  
> The price of the stock changes, say, once every minute.
> 
> Assume that a Rails application detects a change to the price and wants  
> to push the change out to the users without the users needing to do  
> anything? How does one make that happen?

One doesn’t, at least not without using Flash, Java, or Comet. Web  
technologies don’t do push.

The best you can do is to have the client poll the server every so  
often.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [May 7, 2010, 4:42pm UTC](https://www.ruby-forum.com/t/server-detects-change-in-data/188205/3 "2010-05-07T16:42:29Z")

</div>

On May 7, 3:35 pm, Marnen Laibow-Koser [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Assume that a Rails application detects a change to the price and wants  
> > to push the change out to the users without the users needing to do  
> > anything? How does one make that happen?
> 
> One doesn’t, at least not without using Flash, Java, or Comet. Web  
> technologies don’t do push.

or Web Sockets soon (trunk builds of Firefox & Google chrome support  
this I believe)

Fred

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [May 7, 2010, 4:45pm UTC](https://www.ruby-forum.com/t/server-detects-change-in-data/188205/4 "2010-05-07T16:45:07Z")

</div>

Marnen Laibow-Koser wrote:

> One doesn’t, at least not without using Flash, Java, or Comet. Web  
> technologies don’t do push.
> 
> The best you can do is to have the client poll the server every so  
> often.

Can this polling be done with jQuery? Can one point to an example?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [May 7, 2010, 4:45pm UTC](https://www.ruby-forum.com/t/server-detects-change-in-data/188205/5 "2010-05-07T16:45:25Z")

</div>

You could have a page with some javascript that polls your main server  
every  
X seconds and redraw the page as required.

However with a lot of users and a small value of X your server is going  
to  
complain.

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [May 7, 2010, 4:53pm UTC](https://www.ruby-forum.com/t/server-detects-change-in-data/188205/6 "2010-05-07T16:53:51Z")

</div>

Marnen Laibow-Koser wrote:

> > Can one point to an example?
> 
> Do you really need an example? It’s just a matter of periodically  
> making Ajax requests (or refreshing a page, which is the same thing on  
> the server side).

Yes, a nice small Ajax query being made from javaScript or jQuery would  
be very nice.

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [May 7, 2010, 4:50pm UTC](https://www.ruby-forum.com/t/server-detects-change-in-data/188205/7 "2010-05-07T16:50:15Z")

</div>

Ralph S. wrote:

> Marnen Laibow-Koser wrote:
> 
> > One doesn’t, at least not without using Flash, Java, or Comet. Web  
> > technologies don’t do push.
> > 
> > The best you can do is to have the client poll the server every so  
> > often.
> 
> Can this polling be done with jQuery?

Yes.

> Can one point to an example?

Do you really need an example? It’s just a matter of periodically  
making Ajax requests (or refreshing a page, which is the same thing on  
the server side).

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
