title: How to Use Sprockets Gem Properly with Rails 4
body: <p>As a bit of pre-text, I am used to Rails 2 but started building a sample app to get used to Rails 4 and I am having a nightmare with Sprockets and the asset pipeline even after reading the official guide and every question I can find on SO.</p>
  
  <p>My css and js are included like so in my main view file:</p>
  
  <pre><code>&lt;head&gt;
     ...
    &lt;%= stylesheet_link_tag "application", media: "all" %&gt;
    &lt;%= stylesheet_link_tag "style-responsive", media: "all" %&gt;
  
    &lt;%= stylesheet_link_tag params[:controller], :media =&gt; "all" if stylesheet_exists?(params[:controller]) %&gt;
  
    &lt;!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --&gt;
    &lt;!--[if lt IE 9]&gt;
    &lt;%= javascript_include_tag 'html5shiv' %&gt;
    &lt;%= javascript_include_tag 'respond.min' %&gt;
    &lt;![endif]--&gt;
    ...
  &lt;/head&gt;
  
  ....
  
  &lt;%= javascript_include_tag "jquery-1.10.2.min" %&gt;
  &lt;%= javascript_include_tag "jquery-ui-1.9.2.custom.min" %&gt;
  &lt;%= javascript_include_tag "jquery-migrate-1.2.1.min" %&gt;
  &lt;%= javascript_include_tag "bootstrap.min" %&gt;
  &lt;%= javascript_include_tag "modernizr.min" %&gt;
  
  &lt;%= javascript_include_tag params[:controller] if javascript_exists?(params[:controller]) %&gt;
  </code></pre>
  
  <p><code>stylesheet_exists?</code> and <code>javascript_exists?</code> are helper functions as I only want to include certain files when they are needed as opposed to the rest which are needed on every page.</p>
  
  <p>The first error is: </p>
  
  <pre><code>Asset filtered out and will not be served: add `Rails.application.config.assets.precompile += %w( style-responsive.css )` to `config/initializers/assets.rb` and restart your server
  </code></pre>
  
  <p>If I then add that to <code>assets.rb</code> and restart, it moves on and the issue is repeated for every <code>stylesheet_link_tag</code> and <code>javascript_include_tag</code> in my view.</p>
  
  <p>I could live with that even if it doesn't seem right but this comes crashing down when the interpreter gets to</p>
  
  <pre><code>&lt;%= javascript_include_tag params[:controller] %&gt;
  </code></pre>
  
  <p>Would I then need to also include every js file that I create for each controller? This seems wrong that I would have to constantly update the file whenever I create a new asset file.</p>
  
  <p>In my <code>application.css.erb</code> I only have</p>
  
  <pre><code> *= require_self.
  </code></pre>
  
  <p>but I do have the old fashioned CSS <code>@import</code> for some stylesheets:</p>
  
  <pre><code>@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic);
  @import url('bootstrap.min.css');
  @import url('bootstrap-reset.css');
  @import url('jquery-ui-1.10.3.css');
  @import url('&lt;%= asset_path 'css/font-awesome.min.css' %&gt;');
  @import url('custom-ico-fonts.css');
  </code></pre>
  
  <p>but all of these seem to work fine and don't need to be mentioned in <code>assets.rb</code>.</p>
  
  <p>I have no <code>require</code>s set in <code>application.js</code>.</p>
  
  <p><strong>TLDR</strong> I think I am using Sprockets and the Asset Pipeline incorrectly, could someone please point out what it is I'm doing wrong and point me in the right direction?</p>
  
  <p>I read about some similar issues to do with the sprocket-rails gem version 2.2.3 but I have 2.2.4 installed which is meant to have fixed any problems that existed in the previous version.</p>
  
  <pre><code>Rails 4.2.1
  ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
  sprockets (3.0.1, 2.12.3)
  sprockets-rails (2.2.4)
  </code></pre>