Forum: Ruby on Rails Uninitialized Constant in scaffold list page

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
191f8507d514561de78a0afa20494dff?d=identicon&s=25 Strider (Guest)
on 2006-05-18 02:07
I'm new to Ruby on Rails and just trying to get it up and running. I'm
using RadRails, but I don't think that matters for this problem.

I've got a very basic app with one table and I used the scaffold
generator for a table called datedgoals. The new page works fine, but
then when it switches over to the list page, I get the errors below. Any
idea how to fix this? Thanks!

NameError in DatedgoalsController#index
uninitialized constant Datedgoal
RAILS_ROOT: ./script/../config/..

Application Trace | Framework Trace | Full Trace
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
`const_missing'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in
`const_missing'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/inflector.rb:161:in
`constantize'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:in
`constantize'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/pagination.rb:194:in
`paginator_and_collection_for'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/pagination.rb:129:in
`paginate'
#{RAILS_ROOT}/app/controllers/datedgoals_controller.rb:12:in `list'
#{RAILS_ROOT}/app/controllers/datedgoals_controller.rb:3:in `index'
-e:4
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
`const_missing'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in
`const_missing'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/inflector.rb:161:in
`constantize'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:in
`constantize'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/pagination.rb:194:in
`paginator_and_collection_for'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/pagination.rb:129:in
`paginate'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in
`perform_action_without_filters'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in
`perform_action_without_benchmark'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in
`perform_action'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in
`process_without_filters'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in
`process_without_session_management_support'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in
`process'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in
`dispatch'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in
`handle_dispatch'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in
`service'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:173:in
`start_thread'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:162:in
`start_thread'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in
`dispatch'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
script/server:3
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
`const_missing'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in
`const_missing'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/inflector.rb:161:in
`constantize'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:in
`constantize'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/pagination.rb:194:in
`paginator_and_collection_for'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/pagination.rb:129:in
`paginate'
#{RAILS_ROOT}/app/controllers/datedgoals_controller.rb:12:in `list'
#{RAILS_ROOT}/app/controllers/datedgoals_controller.rb:3:in `index'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in
`perform_action_without_filters'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in
`perform_action_without_benchmark'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in
`perform_action'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in
`process_without_filters'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in
`process_without_session_management_support'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in
`process'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in
`dispatch'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in
`handle_dispatch'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in
`service'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:173:in
`start_thread'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:162:in
`start_thread'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in
`dispatch'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
script/server:3
-e:4
This error occured while loading the following files:
   datedgoal.rb
Request
Parameters: None

Show session dump

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


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


HERE IS THE LOG FILE OF THE ERROR:
I don't quit understand the logs yet. If anyone knows of documentation
that explains it, please let me know.

Processing DatedgoalsController#list (for 127.0.0.1 at 2006-05-17
16:40:17) [GET]
  Session ID: 1bd9acaa84affa404d15918ceb8c7f80
  Parameters: {"action"=>"list", "controller"=>"datedgoals"}


NameError (uninitialized constant Datedgoal):
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
`const_missing'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in
`const_missing'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/inflector.rb:161:in
`constantize'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:in
`constantize'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/pagination.rb:194:in
`paginator_and_collection_for'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/pagination.rb:129:in
`paginate'
    /app/controllers/datedgoals_controller.rb:12:in `list'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in
`perform_action_without_filters'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in
`perform_action_without_benchmark'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
    C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in
`perform_action'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in
`process_without_filters'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in
`process_without_session_management_support'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in
`process'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in
`dispatch'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in
`handle_dispatch'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in
`service'
    C:/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in
`service'
    C:/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:173:in
`start_thread'
    C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:162:in
`start_thread'
    C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
    C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
    C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
    C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in
`dispatch'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59
    C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30
    C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
    ./script/server:3
    -e:4


Rendering
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/templates/rescues/layout.rhtml
(500 Internal Error)
241b11f59c4bcfc2ce84a43f52b30001?d=identicon&s=25 Sean Cahoon (osakaboy)
on 2006-05-18 02:57
I'm afraid I can't help you, but I can sympathize รข?? I'm having the exact
same problem. The frustrating thing is that I've done this before and
it's worked fine. I haven't changed my rails settings or updated to a
new version either. The only thing I can think of is that I've been
using "./script/server -e development" or "./script/server -e
production" to explicitly start the server recently instead of just
"./script/server". My scaffold command is just "./script/generate
scaffold model controller". I'm following the AWDWR book to the letter
and it's still not working.
241b11f59c4bcfc2ce84a43f52b30001?d=identicon&s=25 Sean Cahoon (osakaboy)
on 2006-05-18 04:04
Hmm. I'm playing with it and I wonder if it has anything to do with
Rails' naming conventions. Maybe something is capitalized that shouldn't
be, or not capitalized that should. For example, all of my database
table names are in ALL CAPS. When I generate the scaffold, i use
lowercase for the names. I've tried capitalizing them, or capitalizing
the first letters, but that didn't work either. They're all plurals, so
there's no problem there.

Hmm.
191f8507d514561de78a0afa20494dff?d=identicon&s=25 Strider (Guest)
on 2006-05-18 06:29
Thanks for taking a look Sean. I really appreciate it. I was thinking
about naming conventions and capitalization too. I got excited for a
minute when I realized that the example I was following capitalized
something that I didn't. I started a whole new project, following the
steps exactly and capitalizing what they did. But it didn't fix the
problem. Same thing.

I'm trying a more manual work-around now, following the "Rolling with
InstantRails" steps, but in RadRails. We'll see if that works.

If you figure anything out, please let me know!
191f8507d514561de78a0afa20494dff?d=identicon&s=25 Strider (Guest)
on 2006-05-18 06:46
Aha! I got it to work (once at least) I think I know what I did
differently. I suspect that I created the scaffold name plural, when it
should have been singular.

CORRECT:

ruby script/generate scaffold Datedgoal

INCORRECT:

ruby script/generate scaffold Datedgoals

I still not certain that's the difference. Stupid mistake. I doubt
that's the same problem you're seeing, but maybe.

Good luck.

If anyone out there has a better explanation that would help us
understand, and would fix Seans problem, please post.
241b11f59c4bcfc2ce84a43f52b30001?d=identicon&s=25 Sean Cahoon (osakaboy)
on 2006-05-18 07:43
You're right - it works! *high five*

Thanks dude.
This topic is locked and can not be replied to.