There is currently no convenient or “ ” way to transfer information directly from the backend to your views in on Rails. This is particularly inconvenient when trying to transfer information about the progress of a long running process within the backend (such as the processing of an image). It is possible to simply use JavaScript to make XHR/fetch requests every couple of seconds/minutes to request updated information, but it is more of a workaround than an actual solution. natural Ruby This problem has been explored by other developers (such as for Elixir) and the general consensus seems to be to use WebSockets or SSEs to easily and reliably relay information to the frontend from the backend in real time. Tomasz Gryszkiewicz in his work on Drab While Ruby on Rails does provide a framework for WebSockets called Action Cable, it does not provide a convenient way to make frontend modifications once the state of a process changes (which would require to write a new collection of frontend and backend code). Additionally, some work would also need to go into creating and managing individual channels for each user in order to relay the information back to them. Overall, this process is lengthy and needs to be standardized. To solve these problems, there exists a frontend framework for Ruby on Rails called which synchronizes the state of your application between your views and backend over a permanent WebSocket connection. If you have not yet used you can install it in your application using the “ ” and can then follow a simple tutorial that I posted previously which is titled “ ”. fie fie Quick Start Making a Slideshow using Ruby on Rails with no JavaScript The Result Let’s delve into how to simulate and manage long running processes in . fie You probably already know about , which are used by in the same way controllers are used by Ruby on Rails. However, since long running processes are handled by the Active Jobs framework which is external to commanders, has another feature called which injects your classes with the ability to manipulate the state of your user’s views in the same way as the commander. commanders fie fie’s fie [Manipulator](https://fie.eranpeer.co/guide#manipulator) By including within your classes, you provide them with access to basic commander methods which include for viewing and changing the shared state, to execute a JavaScript function from the backend, and to verify whether the commander/client whose state you wish to manipulate still exists. [Manipulator](https://fie.eranpeer.co/guide#manipulator) fie state execute_js_function commander_exists? Your first step to recreating the example displayed in the GIF above is to define your instance variables (or your overall state) within your controller which should look like this: As you can see, two instance variables are created and will be used for the following purpose: keeps track of the progress of our simulated long running job, which is 0 out of 100 at the time of initialization. @long_job_progress , verifies whether the long running job is currently running or not. If we do not keep track of whether the job is already running or not, we risk having the same job run multiple times concurrently, especially if the view does not prevent the user from triggering it multiple times for one reason or another. @is_long_job_running Once your state is initialized in your controller, the next step is to create your view which will display the progress of your long running job to the user: The view may display one of two things depending on whether the job is already running or not (which is represented in the instance variable). @is_long_job_running If the job is already running, the user will see a progress bar equal to the current value of the instance variable and a maximum value of 100. Therefore as the value of changes, so will the progress bar. @long_job_progress @long_job_progress If the job has finished or not yet started, the user will simply see a button that will prompt them to start the long running job. If the user clicks on the button, the commander method will be triggered. start_long_job As the button is currently triggering a method named in our commander and it does not yet exist, we will create it. It should look like this: start_long_job To begin with, if the job is currently running, the method simply exits (through an empty return). Otherwise, the value of is reset to 0 and the long job is set as running through modifying the value of to true. The actual job is then set to run asynchronously through its method. We also pass the identifier of our commander to the job so that the commander can manipulate the state of our commander/view. @long_job_progress @is_long_job_running perform_later @connection_uuid Let’s now create the part we have been waiting for, the actual (in the app/jobs folder): JOB It is first important to note that we include the module through in order to have access to the methods necessary to modify the state from our job. Manipulator include Fie::Manipulator Once we include , the next step is to define the perform method of our job which accepts as an argument the identifier of our commander/view. In order for the methods included from to work, we need to define the instance variable as equal to the of the commander/view whose state we would like to manipulate. After doing so, we can create a lambda literal named which will tell us whether the progress of the job is over 100 or not. Fie::Manipulator connection_uuid Fie::Manipulator @fie_connection_uuid connection_uuid is_job_finished Based on whether the job has finished running or not (meaning the client disconnected or the job completed at a progress of ≥ 100), the job will complete one of two actions. If the client is still connected (verified through the method) and the job is still running (verified through calling ), the value of is increased by 10, and after a waiting period of 1 second, the job is then run again. The user will see it as their progress bar being more complete. commander_exists? is_job_running @long_process_progress Otherwise, the value of is set to false which will notify all other parts of the application that the job has finished running. The user will see this as their progress bar converting into a button again. @is_long_job_running You can try this example at . https://fie.eranpeer.co/showcase#long-running-job Visit the project pages at: or https://fie.eranpeer.co https://github.com/raen79/fie Contact me or ask questions at: or eran.peer79@gmail.com https://gitter.im/rails-fie