# Update a page from the database as changes happen

**URL:** <https://www.ruby-forum.com/t/update-a-page-from-the-database-as-changes-happen/122038>\
**Category:** Rails\
**Created:** [December 4, 2007, 1:52am UTC](https://www.ruby-forum.com/t/update-a-page-from-the-database-as-changes-happen/122038 "2007-12-04T01:52:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henry\_Collingridge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/db5fbb/32.png) [@Henry\_Collingridge](https://www.ruby-forum.com/u/Henry_Collingridge)\
**Post date:** [December 4, 2007, 1:52am UTC](https://www.ruby-forum.com/t/update-a-page-from-the-database-as-changes-happen/122038/1 "2007-12-04T01:52:01Z")

</div>

Hello all,

Could someone point me towards a recipe for getting the content of a  
page to update based on changes in the database (versus updates to  
controls on the page, for example), please?

Ideally I’d like fields on the page to change colour as activity  
occurs asynchronously in the database, so perhaps updates would happen  
in response to a timed event on the server side.

Thanks in advance,

Henry

---

<div class="post-metadata">

**Author:** ![Henry\_Collingridge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/db5fbb/32.png) [@Henry\_Collingridge](https://www.ruby-forum.com/u/Henry_Collingridge)\
**Post date:** [December 4, 2007, 1:54am UTC](https://www.ruby-forum.com/t/update-a-page-from-the-database-as-changes-happen/122038/2 "2007-12-04T01:54:56Z")

</div>

Look at periodically\_call\_remote.

[http://api.rubyonrails.org](http://api.rubyonrails.org)

-Bill

---

<div class="post-metadata">

**Author:** ![Henry\_Collingridge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/db5fbb/32.png) [@Henry\_Collingridge](https://www.ruby-forum.com/u/Henry_Collingridge)\
**Post date:** [December 4, 2007, 9:59pm UTC](https://www.ruby-forum.com/t/update-a-page-from-the-database-as-changes-happen/122038/3 "2007-12-04T21:59:02Z")

</div>

On Dec 3, 2007 6:51 PM, Henry Collingridge  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ideally I’d like fields on the page to change colour as activity  
> occurs asynchronously in the database, so perhaps updates would happen  
> in response to a timed event on the server side.

If you already know when stuff is to change without re-querying the db  
you can use simple javascript:

var seconds = 100  
document.content.fieldFoo.value = ‘100’  
function display()  
{  
document.content.fieldFoo.value = seconds  
if( seconds \> 0 ) seconds -= 1  
if( seconds \<= 0 ) window.location.reload( true );  
setTimeout( ‘display()’, 1000 )  
}  
display()

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
