Puzzled by this error:
NameError in ProductionController#weekly_schedule
uninitialized constant ProductionController::WeeklySchedulePdf
I'm using prawn_rails gem, with the following code from the tutorial at http://www.sitepoint.com/pdf-generation-rails/.
Here's my controller snippet...
class ProductionController < ApplicationController
def weekly_schedule
@tickets = Ticket.where(active: true,
manufacturing_location: session[:factory]).
order(:calendar_date).order(:calendar_order)
if @tickets.size.zero?
@first_day, @last_day = Date.current, Date.current
else
@first_day = @tickets.minimum(:calendar_date)
@last_day = @tickets.maximum(:calendar_date)
#@dayspan = (@last_day - @first_day).to_i
end
vars = [@tickets, @first_day, @last_day]
respond_to do |format|
format.html
format.pdf do
pdf = WeeklySchedulePdf.new(vars)
send_data pdf.render, filename: 'weekly_schedule.pdf', type: 'application/pdf'
end
end
end
And my Prawn file, in app/pdf/weekly_schedule.rb
class WeeklySchedulePdf < Prawn::Document
def initialize(vars)
super
@tickets = vars.first
@first_day = vars.second
@last_day = vars.third
#header
#text_content
#table_content
end