title: How can I correctly deploy static and compiled assets in rails with nginx and capistrano?
body: <p>In my project, I have tried to bundle most of my js libraries into gems so they can be updated and pulled in whenever necessary, however, I've recently setup our production server and I'm having issues with asset compilation and static assets in /public/assets.</p>
  
  <p>Specifically, when I don't use the asset pipeline, I have no issues with datatables or any other JS libraries or css that I am trying to use. I am precompiling my assets in production and using a typical nginx setup (based on railscast #335) to serve them.</p>
  
  <p>Static assets are the following -</p>
  
  <p>public/assets</p>
  
  <pre><code>javascript/jquery.formatCurrency-1.4.0.min.js
  stylesheets/datepicker.css
  twitter/bootstrap/bootstrap-datepicker.js
  </code></pre>
  
  <p>is public/assets the correct place for these?</p>
  
  <p>When I deploy with capistrano, these assets get a 404 when loading the page and are not actually copied to the /public/assets directory on the server.</p>
  
  <p>When loading other pages I am calling the datatables plugin as follows</p>
  
  <pre><code>$('#inventory_item_list_datatable').dataTable
    sDom: "&lt;'row'&lt;'span6'l&gt;&lt;'span6'f&gt;r&gt;t&lt;'row'&lt;'span6'i&gt;&lt;'span6'p&gt;&gt;",
    sPaginationType: "bootstrap",
    iDisplayLength: 100
  </code></pre>
  
  <p>Datatables is compiled into my application.js and doesn't throw an error, but the table never actually renders. I'm wondering if this is related to the order that everything is compiled?</p>
  
  <p>app/assets/javascripts/application.js</p>
  
  <pre><code>//= require jquery
  //= require jquery_ujs
  //= require jquery_nested_form
  //= require twitter/bootstrap
  //= require dataTables/jquery.dataTables
  //= require dataTables/jquery.dataTables.bootstrap
  //= require_tree .
  </code></pre>
  
  <p>app/views/layouts/application.html.erb</p>
  
  <pre><code>&lt;%= stylesheet_link_tag    "application", :media =&gt; "all" %&gt;
  &lt;link href="/assets/stylesheets/datepicker.css" media="all" rel="stylesheet" type="text/css" /&gt;
  
  &lt;%= javascript_include_tag "application" %&gt;
  &lt;script src="/assets/twitter/bootstrap/bootstrap-datepicker.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <p>---edit datatables issue</p>
  
  <p>when using jquery-datatables-rails gem it must be OUTSIDE of your assets group in gemfile.</p>