title: Uncaught ReferenceError: StripeCheckout is not defined in ERB
body: <p>I'm integrating stripe into my RoR app and get the following error when I try to submit test creds:  </p>
  
  <pre><code> Uncaught ReferenceError: StripeCheckout is not defined
  </code></pre>
  
  <p>This behavior is particularly odd because if I simply Refresh/Reload the page and duplicate my exact same steps and submit the same test creds there is no longer any error and the application works perfectly as expected, so the payment goes through successfully.</p>
  
  <p>I'm pretty stumped here.  Any ideas on how to resolve this strange bug?  Thanks!</p>
  
  <p>app/views/pins/_details.html.erb</p>
  
  <pre><code>    &lt;aside id="details-aside" class="col-sm-4"&gt;
          &lt;!-- &lt;a id="btn-buy" href="receipt.html" class="btn btn-success btn-lg btn-block"&gt;&lt;b&gt;I want this!&lt;/b&gt;&lt;/a&gt; --&gt;                 
  
        &lt;% if @pin.user = current_user %&gt;
  
            &lt;%= form_tag charges_path, id: 'chargesForm' do %&gt;
                &lt;script src="https://checkout.stripe.com/checkout.js"&gt;&lt;/script&gt;
                &lt;%= hidden_field_tag 'stripeToken' %&gt;
                &lt;%= hidden_field_tag 'stripeEmail' %&gt;  
                &lt;button id="btn-buy" type="button" class="btn btn-success btn-lg btn-block"&gt;&lt;span class="glyphicon glyphicon-heart"&gt;&lt;/span&gt;   I want this!&lt;/button&gt;
  
                &lt;script&gt;
                    var handler = StripeCheckout.configure({
                      key: '&lt;%= Rails.configuration.stripe[:publishable_key] %&gt;',
                      token: function(token, arg) {
                        document.getElementById("stripeToken").value = token.id;
                        document.getElementById("stripeEmail").value = token.email;
                        document.getElementById("chargesForm").submit();
                      }
                    });
                     document.getElementById('btn-buy').addEventListener('click', function(e) {
                      handler.open({
                        name: 'OMG! &lt;%= @pin.manufacturer %&gt;',
                        description: '&lt;%= @pin.description %&gt;',
                        amount: 1000
                    });
                    e.preventDefault();
                   })
                &lt;/script&gt;
            &lt;% end %&gt;
  
        &lt;% else %&gt;
  
            &lt;%= link_to 'I want this!', new_user_registration_path, class: "btn btn-success btn-lg btn-block" %&gt;
  
        &lt;% end %&gt;
  
      &lt;br&gt;&lt;br/&gt;
  
          &lt;ul id="details-infobox" class="list-group"&gt;
            &lt;li class="list-group-item active clearfix"&gt;DETAILS&lt;/li&gt;
            &lt;li class="list-group-item"&gt;
              &lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt;   &lt;%= @pin.description %&gt;&lt;/p&gt;&lt;/li&gt;
            &lt;li class="list-group-item clearfix"&gt;
              &lt;span class="pull-left content-qualifier"&gt;&lt;b&gt;Price:&lt;/b&gt;&lt;/span&gt;
              &lt;span class="pull-right"&gt;&lt;%= @pin.model %&gt;&lt;/span&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/aside&gt;
  
  &lt;/section&gt;
  </code></pre>
  
  <p>
  </p></p>