2012-07-11 3 views
0

모르겠지만, 나는 이것이 내가 특정 송장을 다운로드하는 방식입니다 하나 개의 요청 만다운로드 배수 파일

에서 PDF 파일의 그룹을 다운로드하려면 :

def show 
    @invoice = Invoice.find_by_invoice_hash params[:hash] 

    respond_to do |format| 
    format.html 
    format.xml do 
     send_data File.read(@invoice.xml_path), type: 'text/xml', filename: "invoice_#{ @invoice.id }.xml", disposition: 'attachment' 
    end 

    format.pdf do 
     render :pdf => @invoice.hash, 
     layout: 'pdf', 
     footer: { 
     right: "printed at: #{Date.today}" 
     } 
    end 
    end 
end 

내가 무엇을 제안합니까?

+0

파일 (zip/tar/etc ..)을 하나의 파일로 보관할 수 있습니다. – deefour

답변

0

HTTP는 사용자가 한 응답으로 보내는 내용에 대해 신경 쓰지 않습니다. 복잡한 응답 데이터를 레일로 전송하려면 this answer을 참조하십시오.

0

HTTP는 한 번에 하나의 파일 만 반환하도록 설계되었습니다. 파일을 함께 압축하거나 압축하여 그 결과를 리턴 할 수 있습니다.