pdfkit发送数据
我正在尝试将 pdf 发送给用户。例如,如果用户位于 /products?category_id=3 中,他必须获取类别 id 为 3 的产品的报告,而不是所有报告。我找不到传递参数的方法。我该怎么做?
products_controller
def index
@products Product.where("category_id = ?", params[:category_id)
end
def reporter
kit = PDFKit.new(render_to_string(:action => "products/index", :layout => "report"))
send_data(kit.to_pdf, :type => :pdf)
end
我的看法是这样的
<% @products.each do |product| %>
<%= product.name %>
<% end %>
<%= link_to "Download(PDF)", reporter_path, :method => :post %>
I'm trying to send pdf to user. For example if user is in /products?category_id=3 he has to get report of products whose category id is 3 not all reports. I couldn't find a way to pass parameter. How can i do this ?
products_controller
def index
@products Product.where("category_id = ?", params[:category_id)
end
def reporter
kit = PDFKit.new(render_to_string(:action => "products/index", :layout => "report"))
send_data(kit.to_pdf, :type => :pdf)
end
My view is like this
<% @products.each do |product| %>
<%= product.name %>
<% end %>
<%= link_to "Download(PDF)", reporter_path, :method => :post %>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论