title: generating pdf hangs on rails 4 using PDFkit gem
body: <p>I'm able to download pdf file with:</p>
  
  <pre><code>curl google.com | wkhtmltopdf - test.pdf
  </code></pre>
  
  <p>so it means, wkhtmlpdf installation was successful.</p>
  
  <p>But, when I try to generate pdf file by accessing <code>http://localhost:3000/contacts/1.pdf</code> it hangs. In the status bar it shows: <code>Waiting for localhost...</code></p>
  
  <p>Rails server output:</p>
  
  <pre><code>Started GET "/contacts/1.pdf" for 127.0.0.1 at 2013-07-28 21:45:06 +0900
    ActiveRecord::SchemaMigration Load (0.1ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  Processing by ContactsController#show as HTML
    Parameters: {"id"=&gt;"1"}
    Contact Load (0.3ms)  SELECT "contacts".* FROM "contacts" WHERE "contacts"."id" = ? LIMIT 1  [["id", "1"]]
    Rendered contacts/show.html.erb within layouts/application (1.4ms)
  Completed 200 OK in 99ms (Views: 57.0ms | ActiveRecord: 0.7ms)
  </code></pre>
  
  <p>Gemfile:</p>
  
  <pre><code>gem 'pdfkit'
  </code></pre>
  
  <p>application.rb:</p>
  
  <pre><code>config.middleware.use "PDFKit::Middleware"
  </code></pre>
  
  <p>According to the <a href="http://railscasts.com/episodes/220-pdfkit" rel="nofollow noreferrer">PDFKit railscast</a> this should be enough for generating pdf files just by adding <code>.pdf</code> ...</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>show.html.erb:</p>
  
  <pre><code>&lt;p id="notice"&gt;&lt;%= notice %&gt;&lt;/p&gt;
  
  &lt;p&gt;
    &lt;strong&gt;Name:&lt;/strong&gt;
    &lt;%= @contact.name %&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
    &lt;strong&gt;Age:&lt;/strong&gt;
    &lt;%= @contact.age %&gt;
  &lt;/p&gt;
  
  &lt;%= link_to 'Edit', edit_contact_path(@contact) %&gt; |
  &lt;%= link_to 'Back', contacts_path %&gt;
  </code></pre>
  
  <p>layouts/application.html.erb:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Pdftest&lt;/title&gt;
    &lt;%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" =&gt; true %&gt;
    &lt;%= javascript_include_tag "application", "data-turbolinks-track" =&gt; true %&gt;
    &lt;%= csrf_meta_tags %&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;%= yield %&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>Thanks to @Arman H for helping me to figure out that I have to specify absolute path for assets instead of a relative ones. When I removed the following lines I was able to generate PDF file:</p>
  
  <pre><code>&lt;%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" =&gt; true %&gt;
  &lt;%= javascript_include_tag "application", "data-turbolinks-track" =&gt; true %&gt;
  </code></pre>
  
  <p>Now, I can't get how to substitute this with an <strong>absolute paths</strong>. It seems this <a href="https://stackoverflow.com/q/7801102/1745902">post</a> is what I need, but I still can't figure out how this would look like for my case.</p>