NameError in CustomersController#index

I'm new to Rails. I finished the Cookbook tut. no problem. I'm
trying to start a project of my own, follow the same instructions but
the difference is I created the database myself.
After I create the scaffolds and try them out I get this error

NameError in CustomersController#index

uninitialized constant Customer

RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace

D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:266:in `load_missing_constant'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:452:in `const_missing'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:464:in `const_missing'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/inflector.rb:250:in `constantize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/core_ext/string/inflections.rb:148:in `constantize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/pagination.rb:195:in `paginator_and_collection_for'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/pagination.rb:130:in `paginate'
#{RAILS_ROOT}/app/controllers/customers_controller.rb:12:in `list'
#{RAILS_ROOT}/app/controllers/customers_controller.rb:3:in `index'
-e:4:in `load'
-e:4

D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:266:in `load_missing_constant'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:452:in `const_missing'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:464:in `const_missing'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/inflector.rb:250:in `constantize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/core_ext/string/inflections.rb:148:in `constantize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/pagination.rb:195:in `paginator_and_collection_for'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/pagination.rb:130:in `paginate'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:1095:in `send'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:1095:in `perform_action_without_filters'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:632:in `call_filter'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:634:in `call_filter'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:619:in `perform_action_without_benchmark'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/benchmarking.rb:66:in
`perform_action_without_rescue'
D:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/benchmarking.rb:66:in
`perform_action_without_rescue'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/rescue.rb:83:in `perform_action'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:430:in `send'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:430:in `process_without_filters'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:624:in
`process_without_session_management_support'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/session_management.rb:114:in `process'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:330:in `process'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
dispatcher.rb:41:in `dispatch'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/rails.rb:78:in `process'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/rails.rb:76:in `synchronize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/rails.rb:76:in `process'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:618:in `process_client'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:617:in `each'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:617:in `process_client'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:736:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:736:in `initialize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:736:in `new'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:736:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:720:in `initialize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:720:in `new'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:720:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/configurator.rb:271:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/configurator.rb:270:in `each'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/configurator.rb:270:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/
mongrel_rails:127:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/command.rb:211:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/
mongrel_rails:243
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:488:in `load'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:488:in `load'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:342:in `new_constants_in'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:488:in `load'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/
servers/mongrel.rb:60
D:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `gem_original_require'
D:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:495:in `require'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:342:in `new_constants_in'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:495:in `require'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/
server.rb:39
D:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `gem_original_require'
D:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require'
script/server:3

D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:266:in `load_missing_constant'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:452:in `const_missing'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:464:in `const_missing'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/inflector.rb:250:in `constantize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/core_ext/string/inflections.rb:148:in `constantize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/pagination.rb:195:in `paginator_and_collection_for'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/pagination.rb:130:in `paginate'
#{RAILS_ROOT}/app/controllers/customers_controller.rb:12:in `list'
#{RAILS_ROOT}/app/controllers/customers_controller.rb:3:in `index'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:1095:in `send'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:1095:in `perform_action_without_filters'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:632:in `call_filter'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:634:in `call_filter'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:619:in `perform_action_without_benchmark'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/benchmarking.rb:66:in
`perform_action_without_rescue'
D:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/benchmarking.rb:66:in
`perform_action_without_rescue'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/rescue.rb:83:in `perform_action'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:430:in `send'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:430:in `process_without_filters'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:624:in
`process_without_session_management_support'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/session_management.rb:114:in `process'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:330:in `process'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
dispatcher.rb:41:in `dispatch'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/rails.rb:78:in `process'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/rails.rb:76:in `synchronize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/rails.rb:76:in `process'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:618:in `process_client'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:617:in `each'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:617:in `process_client'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:736:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:736:in `initialize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:736:in `new'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:736:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:720:in `initialize'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:720:in `new'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel.rb:720:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/configurator.rb:271:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/configurator.rb:270:in `each'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/configurator.rb:270:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/
mongrel_rails:127:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/command.rb:211:in `run'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/
mongrel_rails:243
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:488:in `load'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:488:in `load'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:342:in `new_constants_in'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:488:in `load'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/
servers/mongrel.rb:60
D:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `gem_original_require'
D:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:495:in `require'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:342:in `new_constants_in'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:495:in `require'
D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/
server.rb:39
D:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `gem_original_require'
D:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require'
script/server:3
-e:4:in `load'
-e:4

Request

Parameters: None

Show session dump

It's kind of hard to guess with absolutely no code.
Do you have a file in app/models called customer.rb which contains
the definition of the Customer class?

Fred

Sorry, Like I said i'm pretty new at this.
The files are there but they were empty. I put a "has_many :leases"
to the customer.rb. After doing that I restarted my mongrel server
and get the same error.
All the code in the app is just from running "ruby script\generate
customer customer" the the customer database looks like this:
create_table "customers", :id => false, :force => true do |t|
    t.column "CustID", :integer, :limit => 10, :null => false
    t.column "CustFirst", :string, :limit => 20
    t.column "CustLast", :string, :limit => 30
    t.column "CustCo", :string, :limit => 50
    t.column "CustAddr", :string, :limit => 50
    t.column "CustCity", :string, :limit => 20
    t.column "CustPO", :string, :limit => 7
  end

Doesn't make sense. There is no "customer" generator.

You should be doing:

   ruby script/generate model customer

which will create several things, including a migration in db/migrate
to create the table and a model in app/models/customer.rb (also
creates a unit test and test fixture file).

The app/models/customer.rb needs to contain a model class:

  class Customer < ActiveRecord::Base
    has_many :leases
  end

This declaration assumes a bunch of things:

  * you have a table called "customers"
  * you have another table called "leases" with a "customer_id" integer column
  * you have a model file called app/models/lease.rb, which declares:

     class Lease < ActiveRecord::Base
       belongs_to :customer # not required, but customary
     end

If you're starting an app from scratch, use the generators. They
ensure that everything is created correctly.

Oh, I missed that. So you also need to tell Rails that your id column
is non-standard:

  class Customer < ActiveRecord::Base
    set_primary_key 'CustID'
    ...

  end

sorry I missed the generator on that last e-mail. What I typed to
generate my app was
"ruby script\generate scaffold customers customers" because I created
the database first that way it created my controllers & stuff.

I started from scratch again and run
"ruby script\generate scaffold customers customers"
I run
"ruby script/generate model customers" too just in case I needed it.
I added to customers.rb:
set_primary_key 'CustID'
has_many :leases
and to leases.rb:
belongs_to :customer
I still get the same error

sorry I missed the generator on that last e-mail. What I typed to
generate my app was
"ruby script\generate scaffold customers customers" because I created
the database first that way it created my controllers & stuff.

I started from scratch again and run
"ruby script\generate scaffold customers customers"
I run
"ruby script/generate model customers" too just in case I needed it.
I added to customers.rb:
set_primary_key 'CustID'
has_many :leases
and to leases.rb:
belongs_to :customer
I still get the same error

It's expecting a customer model (in a customer.rb file), since you've
said belongs_to :customer, but instead you've created a customers
model, in customers.rb

Fred

I just missed the 's', in my code is says
belongs_to:customers
Thanks for the help