2
我正在使用wicked_pdf,並且出現問題。該CSS不起作用。如何正確使用?CSS無法在wicked_pdf上工作
我的代碼是這樣的:
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>WickedPdfExample</title>
<%= wicked_pdf_stylesheet_link_tag "bootstrap.min.css" -%>
<%= wicked_pdf_stylesheet_link_tag "application.css" -%>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="container">
<%= yield %>
</div>
</body>
</html>
佈局/ pdf.html.erb
<!DOCTYPE html>
<html>
<head>
<title>PDF</title>
<%= wicked_pdf_stylesheet_link_tag "bootstrap" -%>
</head>
<body>
<div class='container'>
<%= yield %>
</div>
</body>
</html>
customers_controller.erb
def index
@customers = Customer.all
respond_to do |format|
format.html
format.pdf do
render :pdf => 'file_name',
:layout => 'layouts/pdf.html.erb'
:template => 'customers/index.pdf.erb',
:show_as_html => params[:debug].present?
end
end
end
index.pdf.erb
<h1>Listing Customers</h1>
<table class="table table-condensed table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Cpf</th>
<th>Occupation</th>
</tr>
</thead>
<tbody>
<% @customers.each do |customer| %>
<tr>
<td><%= customer.name %></td>
<td><%= customer.cpf %></td>
<td><%= customer.occupation %></td>
</tr>
<% end %>
</tbody>
</table>
有時,出現此錯誤:?
未定義的方法`start_with」爲零:NilClass
我在做什麼錯?
但是,我的bootstrap不收費。我嘗試了所有!
我看到了很多最近。顯然它是由你的css文件中的一個'url(。*)'引起的。任何機會你的項目是開源的,所以我可以更深入地調試它(因爲我很難想象當wicked_pdf gem中的代碼可能失敗時的場景)。 – BroiSatse
作爲參考,有一個公開的問題:https://github.com/mileszs/wicked_pdf/issues/470 – BroiSatse
這是git:請https://github.com/eltonsantos/wicked_pdf_example,請求這個。我嘗試了所有,但沒有任何工作! –