In /app/models/review.rb I have a method that is designed to create a PDF file from the result of the review#print action. Also designed to capture my entire print stylesheet and paste it into the header when I'm in production mode:
def create_pdf snip
I have tried many variations of this code, including passing :layouts => false and more on render .
My reviews_controller.rb contains:
class ReviewsController < ApplicationController respond_to :html filter_access_to :all layout "print", :only => [:print, :pdf] def print snip
My app/views/reviews/print.html.haml contains:
!!! %html %head %title Testivate - if @css.present? = content_tag(:style, @css.html_safe, :type => "text/css") - else = stylesheet_link_tag "print", :media => "print, screen, projection"
Why then do I get the following error when I call @review.create_pdf ?
Rendered reviews/print.html.haml (366.3ms) ActionView::Template::Error: ActionController::Metal
Update:
I tried to create a method from the Controller action on Review, not a class method, but I got the same ActionView::Template::Error: .
Update 2:
The view code in the request to verify it without trying to access the session:
(I do not think so.)
!!! %html %head %title Testivate - if @css.present? = content_tag(:style, @css.html_safe, :type => "text/css") - else = stylesheet_link_tag "print", :media => "print, screen, projection" = csrf_meta_tag = analytics_init if Rails.env.production? %body .header .imagebox =image_tag "Testivate-logo.svg", :width => "300" %h1