title: How do I embed an environment variable into a .coffee file in Rails?
body: <p>I saw this question, but it didn't work: <a href="https://stackoverflow.com/questions/34374229/how-to-access-environment-variable-from-rails-on-your-javascript">How to access environment variable from rails on your javascript?</a></p>
  <p>I have this code</p>
  <code>subscriptions.coffee.erb</code>
  <pre><code>$ -&gt;
    # Create a Stripe client
    stripe = Stripe( &quot;&lt;% ENV['STRIPE_PUBLIC'] %&gt;&quot; )
  </code></pre>
  <p>And I have this environment set</p>
  <pre><code>C:\Users\Chloe\workspace\&gt;echo %STRIPE_PUBLIC%
  pk_test_7aMtxxxxxxxxxxxxx4p3M
  
  C:\Users\Chloe\workspace\&gt;rails server --bind 0.0.0.0
  =&gt; Booting Puma
  </code></pre>
  <p>Yet it is generating this JS:</p>
  <pre><code>http://localhost:3000/assets/subscriptions.self-dfceb50c7f2eec8201fd3f59a7660a6763333b1e27f564e812f93c8ce9019188.js?body=1
  
  (function() {
    $(function() {
      var card, elements, form, stripe, stripeTokenHandler, style;
      stripe = Stripe(&quot;&quot;);
  </code></pre>