SHOW:
|
|
- or go back to the newest paste.
1 | # Rails 3.2.9, Ruby 1.9.3 | |
2 | # wicked_pdf (0.9.2) | |
3 | # wkhtmltopdf (0.1.2) | |
4 | # wkhtmltopdf-binary (0.9.9.1) | |
5 | ||
6 | # Gemfile | |
7 | gem 'wicked_pdf' | |
8 | gem "wkhtmltopdf-binary", "~> 0.9.9.1" | |
9 | ||
10 | # config/application.rb | |
11 | require 'wicked_pdf' | |
12 | config.middleware.use "WickedPdf::Middleware", :print_media_type => true | |
13 | ||
14 | # views/shared/_header.html.erb | |
15 | <%= stylesheet_link_tag "application", :media => "all" %> | |
16 | ||
17 | # assets/stylesheets/application.css | |
18 | @media print { | |
19 | .navbar {display: none;} | |
20 | } | |
21 | ||
22 | # controllers/statements_controller.rb | |
23 | # doesn't seem to be picking up any of the rendering options | |
24 | def show | |
25 | - | @statements_calculator = StatementsCalculator.find_by_id(params[:id]) |
25 | + | @statements = Statements.find_by_id(params[:id]) |
26 | respond_to do |format| | |
27 | format.html | |
28 | format.pdf do | |
29 | render :pdf => 'file_name', | |
30 | :template => 'statements/show', | |
31 | :handlers => [:erb], | |
32 | :formats => [:pdf], | |
33 | :print_media_type => true, | |
34 | :disable_links => true, | |
35 | :disable_internal_links => true, | |
36 | :margin => {:top => 300} | |
37 | end | |
38 | end | |
39 | end | |
40 | ||
41 | # views/statements/show.html.erb | |
42 | <p><%= link_to 'Create PDF document', statement_path(@statement, :format => :pdf) %></p> | |
43 | <%= render :partial => 'show' %> | |
44 | ||
45 | # views/statements/_show.html.erb | |
46 | # irrelevant - working just fine | |
47 | ||
48 | # views/statements/show.pdf.erb | |
49 | # Also tried renaming to show.pdf.html.erb, then specifying in | |
50 | # controllers/statements_controller.rb under :template - no change. | |
51 | # Attempting separate template only because it's not picking up | |
52 | # print media type (to be able to style with @media) | |
53 | <h1>TEST PDF</h1> |