NameError in Controller#index

This is my first time trying to use rails.

I have done nothing beyond generating the scaffolding.

When I try to view any of the generic pages I get this: NameError in <tablename>Controller#index

It happens for every table. This is actually more consistent that the behavior I was getting before. Two of my pages worked just fine but the others would give this error. I tried wiping everything and starting from scratch. Now I get this error everywhere, as comforting as that is.

It will also complain about an uninitialized constant <tablename>

Any help would be greatly appreciated.

NameError in TechniciansController#index

uninitialized constant Technician

RAILS_ROOT: C:/rails_apps/AT/config/.. Application Trace | Framework Trace | Full Trace

c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ dependencies.rb:266:in `load_missing_constant' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ dependencies.rb:452:in `const_missing' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ dependencies.rb:464:in `const_missing' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ inflector.rb:250:in `constantize' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ core_ext/string/inflections.rb:148:in `constantize' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ pagination.rb:195:in `paginator_and_collection_for' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ pagination.rb:130:in `paginate' #{RAILS_ROOT}/app/controllers/technicians_controller.rb:12:in `list' #{RAILS_ROOT}/app/controllers/technicians_controller.rb:3:in `index'

c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ dependencies.rb:266:in `load_missing_constant' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ dependencies.rb:452:in `const_missing' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ dependencies.rb:464:in `const_missing' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ inflector.rb:250:in `constantize' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ core_ext/string/inflections.rb:148:in `constantize' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ pagination.rb:195:in `paginator_and_collection_for' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ pagination.rb:130:in `paginate' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ base.rb:1095:in `send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ base.rb:1095:in `perform_action_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ filters.rb:632:in `call_filter' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ filters.rb:634:in `call_filter' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ filters.rb:619:in `perform_action_without_benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ benchmarking.rb:66:in `perform_action_without_rescue' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ benchmarking.rb:66:in `perform_action_without_rescue' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ rescue.rb:83:in `perform_action' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ base.rb:430:in `send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ base.rb:430:in `process_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ filters.rb:624:in `process_without_session_management_support' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ session_management.rb:114:in `process' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ base.rb:330:in `process' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/dispatcher.rb:41:in `dispatch' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ rails.rb:78:in `process' c:/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ rails.rb:76:in `process' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 618:in `process_client' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 617:in `each' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 617:in `process_client' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 736:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 736:in `initialize' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 736:in `new' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 736:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 720:in `initialize' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 720:in `new' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 720:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ configurator.rb:271:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ configurator.rb:270:in `each' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ configurator.rb:270:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails: 127:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ command.rb:211:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails: 243 c:/ruby/bin/mongrel_rails:18:in `load' c:/ruby/bin/mongrel_rails:18

c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ dependencies.rb:266:in `load_missing_constant' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ dependencies.rb:452:in `const_missing' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ dependencies.rb:464:in `const_missing' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ inflector.rb:250:in `constantize' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/ core_ext/string/inflections.rb:148:in `constantize' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ pagination.rb:195:in `paginator_and_collection_for' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ pagination.rb:130:in `paginate' #{RAILS_ROOT}/app/controllers/technicians_controller.rb:12:in `list' #{RAILS_ROOT}/app/controllers/technicians_controller.rb:3:in `index' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ base.rb:1095:in `send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ base.rb:1095:in `perform_action_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ filters.rb:632:in `call_filter' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ filters.rb:634:in `call_filter' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ filters.rb:619:in `perform_action_without_benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ benchmarking.rb:66:in `perform_action_without_rescue' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ benchmarking.rb:66:in `perform_action_without_rescue' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ rescue.rb:83:in `perform_action' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ base.rb:430:in `send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ base.rb:430:in `process_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ filters.rb:624:in `process_without_session_management_support' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ session_management.rb:114:in `process' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/ base.rb:330:in `process' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/dispatcher.rb:41:in `dispatch' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ rails.rb:78:in `process' c:/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ rails.rb:76:in `process' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 618:in `process_client' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 617:in `each' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 617:in `process_client' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 736:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 736:in `initialize' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 736:in `new' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 736:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 720:in `initialize' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 720:in `new' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb: 720:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ configurator.rb:271:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ configurator.rb:270:in `each' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ configurator.rb:270:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails: 127:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/ command.rb:211:in `run' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails: 243 c:/ruby/bin/mongrel_rails:18:in `load' c:/ruby/bin/mongrel_rails:18

Request

Parameters: None

Show session dump

Unfortunately I'm stuck developing this in Windows.

\app\controllers     application.rb     computers_controller.rb     computer_roles_controller.rb     depts_controller.rb     free_programs_controller.rb     licensed_programs_controller.rb     sites_controller.rb     technicians_controller.rb

\app\models     computers.rb     computer_roles.rb     depts.rb     free_programs.rb     licensed_programs.rb     sites.rb     technicians.rb

It happens with any and all of the controller files. Here is the depts_controller.rb file

class DeptsController < ApplicationController   def index     list     render :action => 'list'   end

  # GETs should be safe (see Index of /2001/tag/doc whenToUseGet.html)   verify :method => :post, :only => [ :destroy, :create, :update ],          :redirect_to => { :action => :list }

  def list     @depts_pages, @depts = paginate :depts, :per_page => 10   end

  def show     @depts = Depts.find(params[:id])   end

  def new     @depts = Depts.new   end

  def create     @depts = Depts.new(params[:depts])     if @depts.save       flash[:notice] = 'Depts was successfully created.'       redirect_to :action => 'list'     else       render :action => 'new'     end   end

  def edit     @depts = Depts.find(params[:id])   end

  def update     @depts = Depts.find(params[:id])     if @depts.update_attributes(params[:depts])       flash[:notice] = 'Depts was successfully updated.'       redirect_to :action => 'show', :id => @depts     else       render :action => 'edit'     end   end

  def destroy     Depts.find(params[:id]).destroy     redirect_to :action => 'list'   end end

The URL I'm accessing is localhost:3000/depts

Have you modified config/database.yml to match your database server settings and run migrations(rake db:migrate)?

Sounds kind of like the errors you get when it can't find the database tables that correspond with the models.

I'd modified database.yml but not run migrations. I'll try it after I get back from lunch.

Still no luck. Same errors. This is the output I got from the rake db:migrate

(in C:/rails_apps/AT) == CreateTechnicians: migrating

This is the last line in my development.log file:

Rendering c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/templates/rescues/layout.rhtml (500 Internal Error)

alright, I think I found it.

\app\models     computers.rb     computer_roles.rb     depts.rb     free_programs.rb     licensed_programs.rb     sites.rb     technicians.rb

uninitialized constant Technician

Model names should be singular, controllers plural.

The assumption is that if you are talking about the TechniciansController and Technicians table that the model representing it will be called Technician.

From your model directory it looks like all of the models are named as

plurals.

If you have already defined things in the models you'll probably just want to rename the files, and then open then and rename them in the: def Technicians < ActiveRecord::Base line to be def Technician < ActiveRecord::Base

Or you can use script/destroy to get rid of stuff and script/generate to create it back.

Just note that when you are generating scaffolding you should pass the singular version: script/generate scaffold technician It will automatically create the pluralized migration and controller stuff.

Thanks!!!

I love it when I'm my own problem.

Thanks again, now I can proceed to break it in new ways.

That is definately an easy problem to miss, I still do it sometimes.

Good luck.