私は現在 Rails 3.1 を実行しており、PDF 生成には最新バージョンの Wicked_pdf を使用しています。すべてが正しく設定されており、PDF は問題なく生成されます。
ただし、ユーザーがボタンをクリックしてpdfをダウンロードできるようにしたいと考えています。現時点では、クリックすると、ブラウザーは pdf をレンダリングし、ページに表示します。
<%= link_to "Download PDF", { :action => "show", :format => :pdf }, class: 'button nice red large radius', target: '_blank'%>
私のコントローラー。
def show
@curric = Curric.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @curric }
format.pdf do
render :pdf => @curric.name + " CV",
:margin => {:top => 20,
:bottom => 20 }
end
end
end
私はsend_fileを指摘されましたが、このシナリオでそれを使用する方法がまったくわかりません.
どんな助けでも大歓迎です。