Ruby on rails S3上存储系统生成的PDF
已解决,请参见底部的编辑Ruby on rails S3上存储系统生成的PDF,ruby-on-rails,heroku,amazon-s3,pdfkit,Ruby On Rails,Heroku,Amazon S3,Pdfkit,已解决,请参见底部的编辑 在我的3.1 rails应用程序中,我生成的pdf如下所示: def show @contributor = Contributor.find(params[:id]) respond_to do |format| format.pdf { html = render_to_string(:action => "show.html.erb") kit = PDFKit.new(html) kit.styleshee
在我的3.1 rails应用程序中,我生成的pdf如下所示:
def show
@contributor = Contributor.find(params[:id])
respond_to do |format|
format.pdf {
html = render_to_string(:action => "show.html.erb")
kit = PDFKit.new(html)
kit.stylesheets << "#{Rails.root}/app/assets/stylesheets/unique/print.css"
thepdf = send_data kit.to_pdf, :filename => "blah.pdf", :type => 'application/pdf'
redirect_to :action => save_to_s3
}
end
哦,我的错,你可以
所以这是可行的:
def show
@contributors = Contributor.where(:client_id => current_user.client_id).paginate(:page => params[:page])
@contributor = Contributor.where(:client_id => current_user.client_id).find(params[:id])
respond_to do |format|
format.html
format.pdf {
html = render_to_string(:action => "show.html.erb")
kit = PDFKit.new(html)
kit.stylesheets << "#{Rails.root}/app/assets/stylesheets/unique/print.css"
send_data kit.to_pdf, :filename => "name.pdf", :type => 'application/pdf'
@thepdf = kit.to_file("#{Rails.root}/tmp/name.pdf")
roy = Royarchive.new(:client_id => @contributor.client_id)
roy.pdf = @thepdf
roy.save!
}
end
end
def save_to_s3
html = render_to_string(:action => "show.html.erb")
kit = PDFKit.new(html)
kit.stylesheets << "#{Rails.root}/app/assets/stylesheets/unique/print.css"
thepdf = kit.to_file("#{Rails.root}/tmp/name.pdf")
roy = Royarchive.new(:client_id => @contributor.client_id)
roy.pdf = thepdf
roy.save!
redirect_to :action => index
end
def保存到\u s3
html=render_to_字符串(:action=>“show.html.erb”)
kit=PDFKit.new(html)
kit.stylesheets@contributor.client_id)
roy.pdf=thepdf
罗伊,救命!
将_重定向到:action=>index
结束
我会的-在写下你自己的问题8小时内,你需要比我回答,更不用说接受更多的代表。
def save_to_s3
html = render_to_string(:action => "show.html.erb")
kit = PDFKit.new(html)
kit.stylesheets << "#{Rails.root}/app/assets/stylesheets/unique/print.css"
thepdf = kit.to_file("#{Rails.root}/tmp/name.pdf")
roy = Royarchive.new(:client_id => @contributor.client_id)
roy.pdf = thepdf
roy.save!
redirect_to :action => index
end