Topic: Problem with table name

I have a table named "database" within a db2 database. After running scaffolding and calling the URL http://localhost:3000/databases I get the following exception:



/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in `const_missing'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in `const_missing'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/inflector.rb:161:in `constantize'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:in `constantize'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:194:in `paginator_and_collection_for'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:129:in `paginate'
app/controllers/databases_controller.rb:12:in `list'
app/controllers/databases_controller.rb:3:in `index'

/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in `const_missing'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in `const_missing'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/inflector.rb:161:in `constantize'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:in `constantize'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:194:in `paginator_and_collection_for'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:129:in `paginate'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform_action_without_filters'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform_action'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process_without_filters'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in `handle_dispatch'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in `service'
/usr/local/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/local/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in `dispatch'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
/usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
/usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
script/server:3

/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in `const_missing'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in `const_missing'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/inflector.rb:161:in `constantize'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:in `constantize'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:194:in `paginator_and_collection_for'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:129:in `paginate'
app/controllers/databases_controller.rb:12:in `list'
app/controllers/databases_controller.rb:3:in `index'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform_action_without_filters'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform_action'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process_without_filters'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in `handle_dispatch'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in `service'
/usr/local/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/local/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/local/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in `dispatch'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
/usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
/usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
script/server:3

This error occured while loading the following files:
   databasis.rb

The name of the model file must be database.rb not databasis.rb.

Any ideas ?

Thx for answer

Re: Problem with table name

"This error occured while loading the following files:
   databasis.rb

The name of the model file must be database.rb not databasis.rb."

Does that help?

http://danielfischer.com - Personal Web-Technology-Blog, Los Angeles.

Re: Problem with table name

I also had this same problem but was able to fix it.  I am using Oracle.


First I named a table "databases". 

Then created a scaffold:   > ./script/generate scaffold database

Here is my error from "development.log" ( webrick )


LoadError (Expected script/../config/../app/models/databasis.rb to define Databasis):
    .//vendor/rails/activesupport/lib/active_support/dependencies.rb:249:in `load_missing_constant'
    .//vendor/rails/activesupport/lib/active_support/dependencies.rb:452:in `const_missing'
    .//vendor/rails/activesupport/lib/active_support/dependencies.rb:464:in `const_missing'
    .//vendor/rails/activesupport/lib/active_support/inflector.rb:250:in `constantize'
    .//vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'
    .//vendor/rails/actionpack/lib/action_controller/pagination.rb:195:in `paginator_and_collection_for'
    .//vendor/rails/actionpack/lib/action_controller/pagination.rb:130:in `paginate'
    .//app/controllers/databases_controller.rb:12:in `list'
    .//app/controllers/databases_controller.rb:3:in `index'


To fix I generated a "scaffold_resource":

         > ./script/generate scaffold_resource database

Not sure about inner workings of the issue. but the error went away.

Matt

Last edited by mmiller (2007-01-31 18:21:25)

Re: Problem with table name

Table name is the plural of the model name with the first letter lowercased.