简体   繁体   中英

Updating ruby on rails app with jQuery every time there is a change

I Want to make an app with ruby on rails and Jquery that will allow multiple users to have the same page open at the same time, and if any of them makes a change to the page, adds a post, or deletes a post it will show all other users that change without having to reload the page.

Here in stack-overflow, whenever another user comes and gives me a point or removes a point on the post, it will show me without having to refresh the page.

Same with the comments, if someone posts, I will see it without having to refresh. Can anyone tell me here to get started with this? I would rather not have to have the page reload every 30 seconds.

Any help would be appreciated.

Thank you in advance.

There are a few ways to go about this:

  1. Websockets
  2. Server Sent Events via ActionController::Live (Rails 4+)
  3. Long Polling (outdated method at this point)

Between websockets and SSE I would go with the former. Higher browser compatibility and the more mature technology of the two. If you're willing to pay for convenience, check our Pusher (solid free tier). Otherwise you might want to check out something like Faye (good intro at http://railscasts.com/episodes/260-messaging-with-faye ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM