I have a js file used for Recurly:
(function() {
// Required
Recurly.config({
subdomain: 'MYSUBDOMAIN',
currency: 'USD'
});
})();
I’d like to be able to switch the subdomain attribute based on my Rails environment but keep this javascript available to the asset pipeline. Is this possible within asset pipeline or what is the best way to achieve the equivalent functionality?
It’s a disappointingly hacky solution but you could set a global variable in the
<head>of your document before your asset pipelined JS is included and then use that variable later, e.g.:In your
application.html.erb:And in your JS: