在Rails购物车页面中使用Javascript时获取NameError

时间:2015-05-13 18:04:44

标签: javascript ruby-on-rails stripe-payments

我很高兴将Javascript与Rails集成。我现在正在使用它在我的客户的在线商店中设置结帐按钮,this very straightforward tutorial基本上只是takes the code straight from Stripe's own documentation。然而,当我尝试显示购物车时,我收到此错误:

NameError in CartsController#show
uninitialized constant ActionView::CompiledTemplates::Settings
Extracted source (around line #9):

6  </article>
7
8
9  <script src="https://checkout.stripe.com/checkout.js" class="stripe-button">
10  data-key="<%= Settings[Rails.env]['stripe']['publishable_key'] %>"
11  data-description="Your payment description"
12  data-amount="<%= @amount * 100 %>">

app/views/carts/show.html.erb:9:in `block in _app_views_carts_show_html_erb__1517017895068716151_26976320'
app/views/carts/show.html.erb:3:in `_app_views_carts_show_html_erb__1517017895068716151_26976320'

现在我已将show.html.erb从自定义更改为简单版本的Stripe的付款方式,但我在同一个方面遇到同样的错误:

&#13;
&#13;
<div class="shopping-cart">
  <%= render "shopping_cart" %>
    <%= form_tag charges_path do -%>
      <article>
        <%= label_tag 'amount', 'To Pay', class: 'amount' %>
          <%= label_tag 'amount', "$#{@amount}.00", class: 'amount-figure' %>
      </article>

      <script src="https://checkout.stripe.com/checkout.js" class="stripe-button">
        data-key = "<%= Settings[Rails.env]['stripe']['publishable_key'] %>"
        data-description = "Your payment description"
        data-amount = "<%= @amount * 100 %>" >
      </script>
      <% end %>
&#13;
&#13;
&#13;

我只能想象我在这里错过了一些完全显而易见的东西,但它却击败了我。任何建议都会受到欢迎。

0 个答案:

没有答案