title: Ruby on Rails routes prefixes not pre-processing in .erb.js file
body: <p>I'm using Rails 4. I have the following file:</p>
  
  <pre><code>// apps/assets/javascripts/products.js.erb
  
  var getColoursAndMaterialsData = function(onSuccess)
  {
      var fd = formdata();
  
      $.post( '&lt;%= data_products_path(:format =&gt; :json) %&gt;', fd )
      .done(function(data)
      {
          onSuccess(data);
      });
  };
  </code></pre>
  
  <p>When products.js.erb is included in a .html.erb file I get the error:</p>
  
  <pre><code>undefined method `data_products_path'
  </code></pre>
  
  <p>clearly routes prefix 'data_products_path' isn't being pre-processed. I was under the impression that giving the products.js the .erb extension would coax the pre-processor.</p>
  
  <p>The same exact same code works when between the <code>&lt;script type="text/javascript"&gt;&lt;/script&gt;</code> tags in the .html.erb file. The relevant part of my routes.rb looks like this:</p>
  
  <pre><code>resources :products do
      collection do     
          post 'data'
      end
  end
  </code></pre>
  
  <p>Is there something else I need to do?</p>