forrest/prawnto — Issue #8: Downloading a rendered file from another controller
Author: vfrride
Created: 2012-02-23 19:50:18+00:00
State: open

When rendering a pdf from another controller, how can you get it to prompt file save instead of rendering in the browser?

When I call invoices controller directly, the file downloads instead of appearing in the browser which is the desired behavior:

class InvoicesController < ApplicationController
def show
respond_to do |format|
format.pdf do
format.pdf { prawnto filename: "Invoice #{@invoice.number}", :inline => false }
end
end
end
end

the following controller renders the pdf in browser instead of prompting a download:

def OtherController < ApplicationController
def show
render "invoices/show.pdf", inline: false
end
end

Any suggestions on how to get that to prompt a download?

Thanks!