我正在与Wicked_PDF合作为我的应用程序生成pdf文件。通常,大多数示例都基于显示页面生成它,但是我希望链接指向索引页面的pdf。
产品负责人
def index
@search = Product.search(params[:q])
@products = @search.result.includes(:supplier, :prodcategory, :prodstatus)
respond_to do |format|
format.html
format.pdf do
render :pdf =>"product_report", :template => 'products/index.html.erb'
end
end
end
产品索引
<p><%= link_to "Printable Invoice (PDF)", products_path(@products, format:"pdf") %></p>
我肯定知道localhost:3000 / products.pdf可以很好地生成它,但是我在确定链接的正确路径时遇到了问题。