Reputation: 14269
I would like the data on a page to update as soon as it changes in database. Is there a way I can trigger some event on server when data changes and send it to the client?
For example a user might see the number of friend requests he has and that number should update in realtime if some other user adds that user as a friend.
Upvotes: 4
Views: 2009
Reputation: 2318
If i m not wrong, then you are trying to write a Rails application in which a server can push data to multiple clients in real time. Their are many guides that involve real-time push, and Rails 3.
You can try juggernaut to do what you want. The github repository : https://github.com/maccman/juggernaut Example of application with juggernaut : https://github.com/maccman/holla
Check out Faye: http://faye.jcoglan.com/ - I hear really good things about it. if you're looking for a hosted solution, i've used Pusher http://pusher.com/ in the past, and loved it. i converted a site that used ajax polling over to pusher in about 30 minutes.
You could use APE (Ajax Push Engine) Rails plugin. APE is a full-featured OpenSource solution designed for Ajax Push. It includes a comet server and a Javascript Framework. APE allows to implement any kind of real-time data streaming to a web browser, without having to install anything on the client-side.
I hope this helps you.
Thanks
Upvotes: 1
Reputation: 8638
This is a brand new feature in Rails 4 (Server sent events). There is a Rails Cast on this topic.
Upvotes: 5