Call a rail's action after PDF generation process is completely finished. - PRAWN + RAILS
I'm using PRAWN to generate a pdf book in Rails. In my application, I need to find the file-size of thus generated pdf book. So, I'm looking for a way that calls another开发者_开发问答 action (which evaluates the file size ) when the pdf generation process is completely finished. Is there a way which I can put the code at the end of Prawn file that calls that action ? Or any another option - which waits until the pdf generation process is over and then calls that action ?
Any sort of hint will be greatly appreciated.
It might be worth trying resque out for this sort of thing
In Rails, an action
is a public instance method on a controller which serves as an endpoint to which certain matching HTTP requests are routed. An action
is intimately tied to the here-and-now of the HTTP request for which the action
is the endpoint and the HTTP response which the action
is building.
This may be semantics, but you don't want to call an action after completion of a long-running background job.
Instead, whatever that code is that needs to run after completion of a long-running background job, that code should be in the model or in some utility class.
See delayed_job and resque for implementations of background job queues/runners that are simple to use in Rails.
delayed_job also allows you to create asynchronous jobs
精彩评论