Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 缺少模板费用/新的,应用程序/_Ruby On Rails_Missing Template - Fatal编程技术网

Ruby on rails 缺少模板费用/新的,应用程序/

Ruby on rails 缺少模板费用/新的,应用程序/,ruby-on-rails,missing-template,Ruby On Rails,Missing Template,因此,当我访问我的 缺少模板费用/新的、应用程序/新的 这是我的费用\u控制器.rb <%= 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

因此,当我访问我的

缺少模板费用/新的、应用程序/新的

这是我的费用\u控制器.rb

<%= 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 %>
类ChargesController<应用程序控制器

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 %>

点击按钮!

任何想法。感谢

当我们在文件名之前附加
\u
时,它被视为部分而不是查看文件。请在
new.html.erb
之前删除
(下划线)。它会起作用。

按照Athar的建议,只需将
\u new.html.erb
重命名为
new.html.erb
。如果这解决了你的问题,你应该接受阿萨的回答。