Skip to content
This repository

Use EM to display a .pdf #320

xb29 opened this Issue · 0 comments

2 participants

xb29 Aman Gupta
xb29 commented

Hi all,

I am new to Rails and EM, and I am trying to accomplish a specific task asynchronously.

In my view, i have a button which invokes a method in my controller which is called "pdfreactor".
Its aim is to generate a .pdf (by launching a .bat which is doing some stuff...) and then to display the .pdf on the client side.
As it can last more than 15 seconds, i am trying to do it asynchronously by using EM, but my .pdf is not displayed.
This is my code :
def pdfreactor

# some stuff

EventMachine::run do

# my job
job = lambda do
system @my_bat_file #Generate a .pdf (path : @varWhichContainAPath)
test = @varWhichContainAPath
callback = lambda do |test|
# Open the .pdf file
send_file(test, :type => 'application/pdf')

EventMachine::defer job, callback

respond_to do |format|
format.html { redirect_to @my_url}


  • When I click on my button, i am redirect_to @my_url
  • The job works, my .pdf file is created
  • However, send_file does not display any .pdf on the client side (there is no error in my prompt and if I use the method synchronously with a file which is already created, my send_file syntax works)

As I am pretty new to the asynchronous development, I think I am missing something.
Do you have any idea about my prob ?


Aman Gupta tmm1 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.