Tutorial :executing code in rails after response sent to browser


Does Rails provide a way to execute code on the server after the view is rendered and after the response is sent to the browser?

I have an action in my application that performs a lot of database transactions, which results in a slow response time for the user. What I'd like is to (1) perform some computations, (2) send the results of those computations to the browser, and then (3) save the results to the database.


It sounds like you want to implement a background job processor. This allows you to put the job into a queue to be processed asynchronously and for your users to not notice a long page load.

There are many options available. I have used and had no issues with delayed_job. Another popular one lately, which I have not used is resque.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »