尝试使用wicked_pdf gem将HTML转换为PDF时出现以下错误:
pairs = s.scan /"(\d+)"=>"([[:upper:]]+)"/
# [["1430156203913", "ABC"],
# ["1430156218698", "DEF"],
# ["1430156219763", "GHI"],
# ["1430156553620", "JKL"],
# ["1430156793764", "MNO"],
# ["1430156799454", "PQR"]]
查看/用户/ index.html.erb:
Hash[pairs].invert.values_at('ABC', 'DEF')
# ["1430156203913", "1430156218698"]
查看/用户/ download_pdf.pdf.erb:
RuntimeError in UsersController#download_pdf
Error: Failed to execute:
["C:\\Ruby193\\lib\\ruby\\gems\\1.9.1\\gems", "file://C:/DOCUME~1/SUBHRA~1/LOCALS~1/Temp/wicked_pdf20150526-3304-8mtfpn.html", "C:/DOCUME~1/SUBHRA~1/LOCALS~1/Temp/wicked_pdf_generated_file20150526-3304-jstgi.pdf"]
Error: Permission denied - C:\Ruby193\lib\ruby\gems\1.9.1\gems
Rails.root: C:/Site/generate1
Application Trace | Framework Trace | Full Trace
app/controllers/users_controller.rb:7:in `block (2 levels) in download_pdf'
app/controllers/users_controller.rb:6:in `download_pdf'
控制器/ users_controller.rb:
<p>
<%= link_to "Download pdf",download_pdf_path(:format => 'pdf') %>
</p>
初始化/ wicked_pdf.rb:
<h1>Hello pdf</h1>
的Gemfile:
class UsersController < ApplicationController
def index
end
def download_pdf
respond_to do |format|
format.pdf{ render pdf: "download_pdf.pdf.erb"}
end
end
end
请帮我解决此错误并将HTML文件转换为PDF。我正在使用windows-xp