Rails HTML Polling Without Writing JavaScript?

Nikola Đuza
4 min readMay 14, 2019

Write simple HTML polling by writing Ruby on Rails ONLY.

If you did Rails, you’ve probably coded one or two polling mechanisms back in the day. Midway through writing it, an annoying feeling starts creeping in when you have to write that extra JavaScript after coding the Rails part on the server. If you get that feeling, (and even if you don’t), there is now a way to do it without actually writing any JS code. First, let’s dive into idea of polling below.

What is polling?

Polling is a process when a client (our browser in this case) continually sends requests to a server to check if updates are available. Polling is what is called pull technology. It’s often used to emulate push technology. Before we go on, let’s describe these terms:

Pull technology

Definition: Initial request for data originates from a client, and then is responded to.
Example: A web browser requests a web page.

Push technology (also known as push notifications)

Definition: A server publishes data, and a client that is subscribed is receiving data.
Example: A email server transmits an email to an email client.

--

--

Nikola Đuza

Nikola helps developers improve their productivity by sharing pragmatic advice & applicable knowledge on JavaScript and Ruby. https://pragmaticpineapple.com/ 🍍