What is a NameError?

Hi,

What is a NameError? When I visit the root page of my application, I
get an application error. Upon checking the logs, the stack trace is
below. I have also included my environment.rb and routes.rb files, if
that’s helpful. Any direction you can point me in is most
appreciated.

/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:266:in load_missing_constant': uninitialized constant UserObserver (NameError) from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ active_support/dependencies.rb:452:in const_missing’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:464:in const_missing' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ active_support/inflector.rb:250:in constantize’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/core_ext/string/inflections.rb:148:in constantize' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/observer.rb:38:in instantiate_observers’
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/observer.rb:36:in each' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/observer.rb:36:in instantiate_observers’
from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:
212:in load_observers' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb: 108:in process’
from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:
43:in send' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb: 43:in run’
from ./…/config/environment.rb:13
from dispatch.cgi:3:in `require’
from dispatch.cgi:3

===================start
environment.rb=================================

Be sure to restart your web server when you modify this file.

Uncomment below to force Rails into production mode when

you don’t control web/app server and can’t set it the proper way

ENV[‘RAILS_ENV’] ||= ‘production’

Specifies gem version of Rails to use when vendor/rails is not

present
RAILS_GEM_VERSION = ‘1.2.3’ unless defined? RAILS_GEM_VERSION

Bootstrap the Rails environment, frameworks, and default

configuration
require File.join(File.dirname(FILE), ‘boot’)

Rails::Initializer.run do |config|

Settings in config/environments/* take precedence over those

specified here

Skip frameworks you’re not going to use (only works if using

vendor/rails)

config.frameworks -= [ :action_web_service, :action_mailer ]

Only load the plugins named here, by default all plugins in vendor/

plugins are loaded

config.plugins = %W( exception_notification ssl_requirement )

Add additional load paths for your own custom dirs

config.load_paths += %W( #{RAILS_ROOT}/extras )

Force all environments to use the same logger level

(by default production uses :info, the others :debug)

config.log_level = :debug

Use the database for sessions instead of the file system

(create the session table with ‘rake db:sessions:create’)

config.action_controller.session_store = :active_record_store

Use SQL instead of Active Record’s schema dumper when creating the

test database.

This is necessary if your schema can’t be completely dumped by the

schema dumper,

like if you have constraints or database-specific column types

config.active_record.schema_format = :sql

Activate observers that should always be running

config.active_record.observers = :cacher, :garbage_collector

Make Active Record use UTC-base instead of local time

config.active_record.default_timezone = :utc

Add new inflection rules using the following format

(all these examples are active by default):

Inflector.inflections do |inflect|

inflect.plural /^(ox)$/i, ‘\1en’

inflect.singular /^(ox)en/i, ‘\1’

inflect.irregular ‘person’, ‘people’

inflect.uncountable %w( fish sheep )

end

See Rails::Configuration for more options

end

Add new mime types for use in respond_to blocks:

Mime::Type.register “text/richtext”, :rtf

Mime::Type.register “application/x-mobile”, :mobile

Include your application configuration below

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => “mail.mydomain.us”,
:port => 25,
:domain => “mydomain.us”,
:user_name => “admin”,
:password => “password”,
:authentication => :login
}
ActionMailer::Base.raise_delivery_errors = true
=====================end
environment.rb================================

===================start routes.rb=================================
ActionController::Routing::Routes.draw do |map|

The priority is based upon order of creation: first created →

highest priority.

Sample of regular route:

map.connect ‘products/:id’, :controller => ‘catalog’, :action =>

‘view’

Keep in mind you can assign values other than :controller

and :action

Sample of named route:

map.purchase ‘products/:id/purchase’, :controller =>

‘catalog’, :action => ‘purchase’

This route can be invoked with purchase_url(:id => product.id)

You can have the root of your site routed by hooking up ‘’

– just remember to delete public/index.html.

map.connect ‘’, :controller => ‘application’, :action => ‘index’

Allow downloading Web Service WSDL as a file with an extension

instead of a file named ‘wsdl’

map.connect ‘:controller/service.wsdl’, :action => ‘wsdl’

Install the default route as the lowest priority.

map.connect ‘:controller/:action/:id.:format’
map.connect ‘:controller/:action/:id’

map.page ‘:permalink’, :controller => ‘page’, :action => ‘show’
map.signup ‘easy_order/signup’, :controller => ‘page’, :action =>
‘signup’

end
=====================end routes.rb================================

On 4 Jun 2008, at 05:21, [email protected] wrote:

Hi,

What is a NameError? When I visit the root page of my application, I
get an application error. Upon checking the logs, the stack trace is
below. I have also included my environment.rb and routes.rb files, if
that’s helpful. Any direction you can point me in is most
appreciated.

NameError means ‘I couldn’t find that’. do you have a file
user_observer.rb defining a UserObserver class ?

Fred