pdfkit send_data
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 %>
精彩评论