Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8446201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:51:58+00:00 2026-06-10T09:51:58+00:00

I’ve got a very simple app where the flow looks like this: User reads

  • 0

I’ve got a very simple app where the flow looks like this:

User reads some copy, decides they want to purchase the product and fill out the form, see confirmation page.

Something is wrong in my controller but I can’t quite pinpoint it where I’m getting the error Couldn't find Customer without an ID.

class CustomersController < ApplicationController
#  before_filter :load_customer, :only => :show

  def new
    @customer = Customer.new
  end

  def create
    @customer = Customer.new(params[:customer])

    if @customer.save
      session[:customer_id] = @customer.id
      purchase
    else
      flash[:error] = "Please enter a valid email address"
      redirect_to :signup
    end
  end

  def signup
    @customer = Customer.new
  end


  def purchase
    Stripe.api_key = STRIPE['secret']
    charge = Stripe::Charge.create(
    :amount => 2000,
    :currency => "usd",
    :card => params[:stripe_token],
    :description => "My Product Name"
    )
    redirect_to receipt_path
  end

  def receipt
    @customer = Customer.find(session[:customer_id])

    @name = @customer.name
    @email = @customer.email
    @product = @customer.product
  end

  # private
  # 
  # def load_customer
  #   @customer = Customer.find(session[:customer_id])
  #   redirect_to request.path.gsub(params[:id], session[:customer_id].to_s) if params[:id] != session[:customer_id].to_s
  # end

end

I’m not sure where things are screwing up and after much Googling, I’m turning to you guys. Help would be huge.

EDIT:

Consulting with Rails console shows that my application isn’t making new customer records for some reason. Charging is working, however. Customers not being created must be a precursor to this.

EDIT 2: Development.log

Started GET "/assets/bootstrap.js?body=1" for 127.0.0.1 at 2012-08-28 15:58:11 -0700
Served asset /bootstrap.js - 304 Not Modified (0ms)
[2012-08-28 15:58:11] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true


Started POST "/checkout" for 127.0.0.1 at 2012-08-28 15:58:12 -0700
Processing by CustomersController#purchase as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"k2aW/CAkNfwDSMHHvzbuOwm+Xua0qb2LJ4LtrtRvyvk=", "customer"=>{"name"=>"Your name", "email"=>"yourname@example.com"}, "stripe_token"=>"tok_0GUvwKPwo6jfEu"}
Redirected to http://localhost:3000/receipt
Completed 302 Found in 1064ms (ActiveRecord: 0.0ms)


Started GET "/receipt" for 127.0.0.1 at 2012-08-28 15:58:14 -0700
Processing by CustomersController#receipt as HTML
Completed 500 Internal Server Error in 0ms

ActiveRecord::RecordNotFound (Couldn't find Customer without an ID):
  app/controllers/customers_controller.rb:38:in `receipt'


  Rendered /Users/zack/.rvm/gems/ruby-1.9.3-p194@beat-the-herd/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (3.9ms)
  Rendered /Users/zack/.rvm/gems/ruby-1.9.3-p194@beat-the-herd/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (5.6ms)
  Rendered /Users/zack/.rvm/gems/ruby-1.9.3-p194@beat-the-herd/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (23.7ms)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:52:00+00:00Added an answer on June 10, 2026 at 9:52 am

    If the user routes directly to receipt action then session[:customer_id] may be nil. That’s why you get the error. This is not happened if a create (possibly) POST request is issued. In this case, the session variable has been populated before the redirection to the receipt action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.