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

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:inconst_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:inconstantize’
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:inpaginator_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:inlist’
#{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:inconst_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:inconstantize’
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:inpaginator_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:insend’
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:incall_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:inperform_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:inmeasure’
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:inperform_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:inprocess_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:inprocess’
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:indispatch’
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:insynchronize’
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:inprocess_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:inprocess_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:ininitialize’
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:inrun’
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:innew’
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:inrun’
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:inrun’
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:inrun’
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:inconst_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:inconstantize’
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:inpaginator_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:inlist’
#{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:insend’
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:incall_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:inperform_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:inmeasure’
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:inperform_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:inprocess_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:inprocess’
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:indispatch’
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:insynchronize’
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:inprocess_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:inprocess_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:ininitialize’
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:inrun’
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:innew’
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:inrun’
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:inrun’
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:inrun’
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


flash: !map:ActionController::Flash::FlashHash {}

Response
Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}

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 http://www.w3.org/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

On Feb 8, 11:06 am, Keynan P. [email protected]

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.

please specify the contents of

/app/controllers,
/app/models,
the controller file in question
and the url you are attempting to access it with
(and any applicable routing information.

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)

On Feb 8, 12:57 pm, “[email protected][email protected]

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

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

– create_table(:technicians)
NOTICE: CREATE TABLE will create implicit sequence
“technicians_id_seq” for ser
ial column “technicians.id”
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"technicians_pkey
" for table “technicians”
-> 0.2650s
== CreateTechnicians: migrated (0.2650s)

I tried for technicians and for others but no go.

On Feb 8, 11:41 am, “[email protected][email protected]

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.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs