Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

removing pdfkit middleware

  • Loading branch information...
commit b6cdbbe63252b4e1dff835d88ce96e452d76aa27 1 parent 7ecf0c3
Omnipresent authored
BIN  app/controllers/.medicalhistories_controller.rb.swp
Binary file not shown
23 app/controllers/medicalhistories_controller.rb
@@ -3,17 +3,24 @@ def index
3 3 @medicalhistories = Medicalhistory.all
4 4 end
5 5
  6 + def pdf
  7 + redirect_to "http://cricinfo.com"
  8 + end
  9 +
6 10 def show
7 11 @medicalhistory = Medicalhistory.find(params[:id])
8   - respond_to do |format|
9   - format.pdf {
10   - html = render_to_string(:layout=>false, :action=>"show.html.erb")
  12 + respond_to do |format|
  13 + format.html # show.html.erb
  14 + format.pdf {
  15 + html = render_to_string(:template => "medicalhistories/show.html.erb")
11 16 kit = PDFKit.new(html)
12   - kit.stylesheets << "#{Rails.root}/public/stylesheets/application.css"
13   - send_data(kit.to_pdf, :filename => "labels.pdf", :type => 'application/pdf')
14   - return
15   - }
16   - end
  17 + kit.stylesheets << "#{Rails.root}/public/stylesheets/pdf.css"
  18 + send_data(kit.to_pdf, :filename => "#{@medicalhistory.fname}.pdf",
  19 + :type => 'application/pdf', :disposition => 'inline')
  20 + return
  21 + }
  22 +
  23 + end
17 24 end
18 25
19 26 def new
BIN  app/views/medicalhistories/.index.html.erb.swp
Binary file not shown
2  app/views/medicalhistories/index.html.erb
@@ -12,7 +12,7 @@
12 12 <td><%= link_to "Show", medicalhistory %></td>
13 13 <td><%= link_to "Edit", edit_medicalhistory_path(medicalhistory) %></td>
14 14 <td><%= link_to "Delete", medicalhistory, :confirm => 'Are you sure?', :method => :delete %></td>
15   - <td><%= link_to "PDF", medicalhistory_path(medicalhistory, :format => "pdf")%></td>
  15 + <td><%= link_to "PDF", medicalhistory_path(medicalhistory, :format => "pdf")%></td>
16 16 </tr>
17 17 <% end %>
18 18 </table>
10 app/views/medicalhistories/show.html.erb
... ... @@ -1,9 +1,9 @@
1   - <%= render :partial => 'about_show', :locals => { :f => @medicalhistory} %>
  1 + <%= render :partial => 'medicalhistories/about_show.html.erb', :locals => { :f => @medicalhistory} %>
2 2
3   - <%= render :partial => 'insurance_show', :locals => { :f => @medicalhistory} %>
  3 + <%= render :partial => 'medicalhistories/insurance_show.html.erb', :locals => { :f => @medicalhistory} %>
4 4
5   - <%= render :partial => 'medical_show', :locals => { :f => @medicalhistory} %>
  5 + <%= render :partial => 'medicalhistories/medical_show.html.erb', :locals => { :f => @medicalhistory} %>
6 6
7   - <%= render :partial => 'dental_show', :locals => { :f => @medicalhistory} %>
  7 + <%= render :partial => 'medicalhistories/dental_show.html.erb', :locals => { :f => @medicalhistory} %>
8 8
9   - <%= render :partial => 'consent_show', :locals => { :f => @medicalhistory} %>
  9 + <%= render :partial => 'medicalhistories/consent_show.html.erb', :locals => { :f => @medicalhistory} %>
2  config/application.rb
@@ -38,7 +38,7 @@ class Application < Rails::Application
38 38
39 39 # Configure sensitive parameters which will be filtered from the log file.
40 40 config.filter_parameters += [:password]
41   - config.middleware.use "PDFKit::Middleware", :print_media_type => true
  41 +# config.middleware.use "PDFKit::Middleware", :print_media_type => true
42 42 #test
43 43 end
44 44 end
BIN  config/environments/.development.rb.swp
Binary file not shown
12 config/environments/development.rb
@@ -23,17 +23,5 @@
23 23 # Only use best-standards-support built into browsers
24 24 config.action_dispatch.best_standards_support = :builtin
25 25
26   - config.action_controller.asset_host = Proc.new { |source, request|
27   - print "Source: " + source
28   - print "\n"
29   - print "request.media_type: " + request.media_type
30   - print "\n"
31   - print "request.format: " + request.format
32   - print "\n"
33   - # if request.host.to_s.match(/pdf/)
34   - #print "CAME HEREEEEEEEEEEEEEEEE"
35   - # end
36   - # source.ends_with?(pdf) "file://#{Rails.root.join('public')}" : "#{request.protocol}#{request.host_with_port}"
37   - }
38 26 end
39 27
5 config/initializers/pdfkit.rb
@@ -2,4 +2,9 @@
2 2
3 3 PDFKit.configure do |config|
4 4 config.wkhtmltopdf = Rails.root.join('bin', 'wkhtmltopdf-amd64').to_s if ::Rails.env == 'production'
  5 + config.default_options = {
  6 + :page_size => 'Legal',
  7 + :print_media_type => true,
  8 + :disable_javascript => true
  9 + }
5 10 end
3  config/routes.rb
... ... @@ -1,12 +1,9 @@
1 1 Dentalassistant::Application.routes.draw do
2   -
3   -
4 2 match "login" => "user_sessions#new", :as => :login
5 3 match "logout" => "user_sessions#destroy", :as => :logout
6 4 resources :users
7 5 resources :user_sessions
8 6 resources :medicalhistories
9   -
10 7 resources :forms
11 8 root :to => 'medicalhistories#new'
12 9
14 public/stylesheets/pdf.css
... ... @@ -0,0 +1,14 @@
  1 +
  2 +label.show_label{
  3 + display: inline-block;
  4 + font-weight: bold;
  5 + text-align: left;
  6 + margin: 2px 10px;
  7 + width: 200px;
  8 +}
  9 +fieldset {
  10 + margin-bottom: 20px;
  11 +}
  12 +legend {
  13 + font-weight: bold;
  14 +}

0 comments on commit b6cdbbe

Please sign in to comment.
Something went wrong with that request. Please try again.