samedi 14 mai 2016

How to customize the attachment file name in ROR?

I have a file which returns a pdf attachment as an output. I am using wicked pdf to generate this pdf.

    def generate_pdf
        render pdf: "#{@user.name}",
                       template: 'api/v1/doctors/get_report_4.html.erb',
                       :page_size => 'Letter',
                       layout: false, disposition: 'attachment',
                       :margin => {bottom: @margin_bottom, top: @margin_top, left: @margin_left, right: @margin_right},
                       wkhtmltopdf: %x(bundle exec which wkhtmltopdf).to_s.strip.presence || %x(which wkhtmltopdf).to_s.strip}

end

But while calling this API. I am getting the attachment with name "response.pdf" instead of username.pdf. Please help me with this.

Aucun commentaire:

Enregistrer un commentaire