2015-07-12 50 views
0

所以我當我訪問我的http://localhost:3000/charges/new缺少模板費用/新,應用/

缺少模板費用/新收到此錯誤,應用程序/新

這裏是我的charges_controller.rb

類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 

這裏是我的意見/費用/ _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 %> 

任何想法。謝謝

+0

只需按照Athar的建議將_new.html.erb重命名爲new.html.erb即可。如果這解決了你的問題,你應該接受Athar的答案。 –

回答

2

當我們追加_之前的文件名被認爲是部分不作爲查看文件。請在new.html.erb之前刪除_(下劃線)。它會工作。