0

So I am getting this error when I visit my http://localhost:3000/charges/new

Missing template charges/new, application/new

Here is my 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

Here is my 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 %>

Any idea. Thanks

goldmullet
  • 15
  • 1
  • Just rename `_new.html.erb` into `new.html.erb` as suggested by Athar. If this solves your question you should accept Athar's answer. – Tim Jul 13 '15 at 02:39

1 Answers1

2

When we append _ before the file name it is considered as partial not as view file. please remove _(underscore) before new.html.erb. it will work.

Kick Buttowski
  • 6,709
  • 13
  • 37
  • 58
Athar
  • 3,258
  • 1
  • 11
  • 16