Reputation:
I'm working on a task that zip and download files with ruby on rails using rubyzip gem, I want to check the last date of download. here is the method the do the job :
def zip_it
report = Report.find( params[ :id ] ).decorate
pdf_filename = report.decorate.attachment_pdf_filename
binding.pry
public_pdf = ReportPdf.new current_company, report, []
public_pdf.generate_pdf( report, "public.pdf" )
internal_pdf = ReportPdf.new current_company, report, [], "internal"
internal_pdf.generate_pdf( report, "internal.pdf" )
zip_pdf( "#{Rails.root}/tmp/pdf/reports/#{report.reference}" )
send_file( "#{Rails.root}/tmp/pdf/reports/#{report.reference}.zip" )
download_date = DateTime.current
binding.pry
end
when i check the download_date variable it return nil !
some help ! thanks
Upvotes: 1
Views: 139
Reputation: 6068
In order for DateTime.current
to work as expected you need to require the library.
Add require 'date'
to fix your issue.
Upvotes: 1