vendredi 16 octobre 2015

Generating report in pdf using pdfkit on the basis of some search parameter

I am new to rails. I want to generate a pdf so for that I have used pdfkit gem. I followed the railcast tutorial but the problem in my case is that first I am searching for the record between the two dates than it redirects to a page and I have to print that page into pdf. The page that i have to generate pdf have some parameters in the address bar like this : http://localhost:3000/report?utf8=%E2%9C%93&mer_report%5Bmerchant_id%5D=32&sdate=2015-06-13&edate=2015-10-13

Help me how i will do that.

View :

<p><%= link_to "Download", report_path %></p>

Controller :

merchant_id     =   params[:mer_report][:merchant_id].to_i
merchant        = Merchant.find(merchant_id)
$merchant = merchant
@merchant_id = merchant.id
@start_date = params[:sdate]
@end_date = params[:edate]
@original_merchant_name  = merchant.name
@total_customer = merchant.users
@total_visits   = merchant.visits.where(checked_in: true)

application.rb :

config.middleware.use "PDFKit::Middleware", :print_media_type => true

Aucun commentaire:

Enregistrer un commentaire