0

したがって、 http://localhost:3000/charges/newにアクセスすると、このエラーが発生します

欠テンプレート料金/新規、申請/新規

これが私のcharges_controller.rbです

class ChargesController < ApplicationController

def new
   @stripe_btn_data = {
     key: "#{ Rails.configuration.stripe[:publishable_key] }",
     description: "BigMoney Membership - #{current_user.name}",
     amount: 15_00
   }
 end


def create


   customer = Stripe::Customer.create(
     email: current_user.email,
     card: params[:stripeToken]
   )


   charge = Stripe::Charge.create(
     customer: customer.id, # Note -- this is NOT the user_id in your app
     amount: Amount.default,
     description: "BigMoney Membership - #{current_user.email}",
     currency: 'usd'
   )

   flash[:success] = "Thanks for all the money, #{current_user.email}! Feel free to pay me again."
   redirect_to user_path(current_user) # or wherever


 rescue Stripe::CardError => e
   flash[:error] = e.message
   redirect_to new_charge_path
 end

end

ここに私のviews/charges/_new.html.erbがあります

<%= form_tag charges_path do %>
   <h4>Click the button!</h4>
   <script 
   class='stripe-button' 
   src="https://checkout.stripe.com/checkout.js" 
   data-key="<%= @stripe_btn_data[:key] %>" 
   data-amount=<%= @stripe_btn_data[:amount] %> 
   data-description="<%= @stripe_btn_data[:description] %>" >
   </script>
 <% end %>

何か案が。ありがとう

4

1 に答える 1

2

ファイル名の前に追加すると、ビューファイルではなく部分的_と見なされます。の前の (アンダースコア)を削除してください。それが動作します。_new.html.erb

于 2015-07-12T20:57:00.350 に答える