Reputation: 19496
Is there anyway I can get an environment variable (like an API key) to appear inside JS/Coffee using Rails 3.1?
Upvotes: 3
Views: 5532
Reputation: 1373
You can rename your file.js to file.js.erb and use ruby to access ENV:
<% do_something_with ENV['key'] %>
some_js_code
Upvotes: 9