JS / Coffeescript中的环境变量

无论如何我可以使用Rails 3.1获得一个环境变量(如API密钥)出现在JS / Coffee中?

您可以将file.js重命名为file.js.erb并使用ruby访问ENV:

 <% do_something_with ENV['key'] %> some_js_code