Rails real-time logger on webpage?

I'm transferring a Ruby app I once made into Rails. Now the app does some calculations that take a while (up to infinity (in theory) if you like :p). To show a user the status of everything, I previously used the console. Now, obviously, I want my browser to show this.

Does anyone has any pointers where to start reading/exmples/gems/ideas? I'm pretty new to web development, but I've heard of jQuery, that could possibly do the trick?

Answers


As per my understanding you have two options to do this

1 - using some kind of a server push method to be implemented. You may use following components

juggernaut (http://juggernaut.rubyforge.org/ ) http://www.ape-project.org/

2 - Using PeriodicalUpdater with JQuery. This will send a request to the server in a given time interval.

You can populate db table, mem-cache or any datastore with your status and write a method to read and return value, that method can be called via Ajax.PeriodicalUpdater

I have done this, but this is killing the performance as it request the server (in mycase it was every 5 seconds)

Even though I personally haven't done, I prefer the server-push option is the methodical way to go

HTH

cheers

sameera


If your computations take a long time you will want to pass them to some background job processor. There are several several gems that can help you do this. Here are a few with tutorial how to use them with Rails.

Providing a web interface to display the processing status of the calculation can be done in a number of ways. One way might be with polling.


Rails live streaming currently in rails 4. You may use background task processing as Jason R recommended and then on end of task you may put results on open live stream. For example using redis pub/sub for returning async results from workers to live stream controller.

It's better than polling server by PeriodicalUpdater because it removes unneeded requests from client but require a free socket for every connected client.


I just find super-tool :) Add this script to your project:

  <script src='https://gist.githubusercontent.com/vitalyp/9441352/raw/5be994fbc78bd2bcc7ad31192f095c888d02f819/myconsole.js'></script>

and somewhere in document.ready (or from browser console), envoke function:

pop_console();

It displays a window with console.log(...) strings.


Need Your Help

Working with OfflineJS and AngularJS

javascript angularjs offline.js

I am working on an angular app where I want to integrate OfflineJS functionality.

MongoDb Remote Server

mongodb ubuntu node.js terminal

I got a work of node.js and mongodb. While running node.js it gives error of permission denied.