I'm using Rails 4. I have the following file:
// apps/assets/javascripts/products.js.erb
var getColoursAndMaterialsData = function(onSuccess)
{
var fd = formdata();
$.post( '<%= data_products_path(:format => :json) %>', fd )
.done(function(data)
{
onSuccess(data);
});
};
When products.js.erb is included in a .html.erb file I get the error:
undefined method `data_products_path'
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.
The same exact same code works when between the <script type="text/javascript"></script>
tags in the .html.erb file. The relevant part of my routes.rb looks like this:
resources :products do
collection do
post 'data'
end
end
Is there something else I need to do?