I got it working without instance eval by turning it the other way around : generate the PDF in your model and render it in you controller
In a model :
def generate_pdf
Prawn::Document.new(:page_size => 'A4', :top_margin => 0, :left_margin => 0) do |pdf|
<your pdf code here>
<copy paste from your template>
end.render
end
You can then send it as a mail attachment :
attachment = generate_pdf
mail = Notifier.send_pdf(attachment)
mail.deliver
Or render it in your browser windows in your controller :
send_data your_model.generate_pdf, :type => "application/pdf", :disposition => 'inline'