Is there anyway I can get an environment variable (like an API key) to appear inside JS/Coffee using Rails 3.1?
You can rename your file.js to file.js.erb and use ruby to access ENV:
<% do_something_with ENV['key'] %>
some_js_code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With