I have a Rails model and in one of the methods I create pdf using such a shrimp,
class Report < ActiveRecord::Base def pdf_output Prawn::Document.new do text "Start date: #{start_date.strftime('%e %b %Y').squish}" end end end
In this text method, I am trying to infer the start_date attribute of my report model. Instead, I get the following error:
NoMethodError in ReportsController#show undefined method `start_date' for #<Prawn::Document:0x007fdafbce6930>
So my start_date method refers to my Document object instead of the Report object. How to access the variables and methods of my report object from this block?
source share