Skip to content

Instantly share code, notes, and snippets.

@muellerj
Created January 24, 2011 07:31
Show Gist options
  • Save muellerj/792939 to your computer and use it in GitHub Desktop.
Save muellerj/792939 to your computer and use it in GitHub Desktop.
PDFKit on Heroku with single Dyno
# ...
def show_pdf
@order = Order.find_by_token(params[:id])
if @order.nil?
flash[:error] = "Couldn't find invoice."
redirect_to root_path
else
pdf = PDFKit.new(render_to_string(:action => 'show', :id => @order.token, :layout => "invoice"))
pdf.stylesheets << "#{Rails.root}/public/stylesheets/invoice.css"
send_data(pdf.to_pdf, :type => 'application/pdf', :disposition => 'inline')
end
end
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment