Forum: Ruby on Rails uninitialized constant CachedModel

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.
vlo (Guest)
on 2009-03-11 01:33
(Received via mailing list)
I just upgraded my app from 1.2.6 to 2.2.2. When I do the rake
db:migrate, I hit "uninitialized constant CachedModel." (Full stack at
the end of the message.) I found out from doing a Google search that
CachedModel and the initialization process created a chicken-and-egg
problem long time ago. However, I thought that the problem was solved
as I didn't have to anything special to make it work in 1.2.6.

BTW, if I move the require 'cached_model' before
Rails::Initializer.run do |config|, it dies somewhere else. And I am
pretty sure that it is not the recommended place for the require
anyway.

Has anyone encountered this problem before? And how did you solve it?

Thanks,
Vincent

P.S. Full stack:

uninitialized constant CachedModel
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:445:in `load_missing_constant'
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:77:in `const_missing'
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:89:in `const_missing'
/usr/local/myapp/app/models/baby.rb:1 (<= class Baby < CachedModel )
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:155:in `require'
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:262:in `require_or_load'
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:221:in `depend_on'
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:133:in `require_dependency'
/usr/lib64/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:368:in
`load_application_classes'
/usr/lib64/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:367:in
`each'
/usr/lib64/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:367:in
`load_application_classes'
/usr/lib64/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:365:in
`each'
/usr/lib64/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:365:in
`load_application_classes'
/usr/lib64/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:185:in
`process'
/usr/lib64/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in
`send'
/usr/lib64/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in
`run'
/usr/local/myapp/config/environment.rb:13 (<= Rails::Initializer.run
do |config|)
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in `require'
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:521:in `new_constants_in'
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in `require'
/usr/lib64/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/misc.rake:3
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in
`invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in
`invoke_with_call_chain'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:588:in
`invoke_prerequisites'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in
`invoke_prerequisites'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:577:in
`invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in
`invoke_with_call_chain'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in
`invoke_task'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in
`top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in
`top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in
`standard_exception_handling'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in
`top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in
`standard_exception_handling'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
vlo (Guest)
on 2009-03-11 02:14
(Received via mailing list)
Well, well, well. Problem solved. I should have reread the release
notes. The easy solution is to use config.gems in environment.rb.

Vincent
This topic is locked and can not be replied to.