Realtime on Rails

I asked about realtime rails stuff on the hangout today and the advice was to post it up here.

How do you all handle realtime features with rails? Like if you have an ecomm site and you want an admin area that has a realtime list of new orders as they are created?

I had to do this a few months back and looked at ActionController::Live for sending SSEs to a redis channel, but ran into issues with the ActionController connection never closing. I ended up using a mess with firebase where rails published to firebase after creating an object and the frontend had a 3-way binding setup with angular + firebase so it could grab the updates from there. It worked, but felt really hacky.

Are there any solid realtime solutions in Rails or is it a problem better solved with node/faye/something else? I saw that elixir’s phoenix framework is being created partially to solve this problem, and that looks like something to keep an eye on.

1 Like

@jferris Didn’t we do a bit of this on Whetstone for displaying when a repo was created?

Never underestimate some simple Ajax polling.

There are so many circumstances that “realtime” is actually totally fine to just poll and update on a regular interval. And that tends to be a ton simpler to create and maintain.


I agree with @cpytel that the best solution is often just regular polling with AJAX.

I haven’t looked at it for a while, but realtime is fiddly to set up. Perhaps consider using a third-party service such as Pusher. I’ve had great success using them in the past, and they provide a Rubygem and Ruby-based tutorials.


For the exercises system, we use Pusher.

We started with Ajax polling, and this worked well for us for a long time. However, several of the main pages of the site need to update after long-running changes (Git machinery, users pushing to repo, etc). It ended up being much faster and more reliable to use Pusher.

I’d recommend starting with some simple polling, and upgrading to a more robust solution if it turns out your site requires it.

1 Like