My code is this:
$.getJSON("/somefolder/somefile.json?"+urlParams, function(json) {
//populate combo here
});
I’m working on Rails, using sass and the file I have this code in is originally a file.js although to work with pipeline assets I already changed it to file.js.erb
In Dev I’m working in http://localhost:XXXX so results are OK.
In Prod I’m using a folder http://domain.com:XXXX/app so the results goes badways.
Coding like <%=image_tag("loading.gif", :class => "loading")%> works perfectly in this file but $.getJSON("<%= controller_method_path %>.json?"+urlParams does not
Any suggestion?
Assuming your routes are setup to use a prefix in production, you should be using the actual routing methods for the full path.
Now the entire path should be generated properly in all cases.
But craziness like this is why it’s usually not recommend to run rails apps in a subdirectory of a domain. It makes routing and relative links to other pages and assets much more of a headache.
If you can host the rails app on a subdomain instead.