Uninitialized constant CachedModel

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:inconst_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:ingem_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:inrequire’
/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:independ_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:inload_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:inload_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:inload_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:insend’
/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:ingem_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:inrequire’
/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:inrequire’
/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:inexecute’
/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:inexecute’
/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:insynchronize’
/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:ininvoke_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:ininvoke_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:insynchronize’
/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:ininvoke’
/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:intop_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:intop_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:intop_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:instandard_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:inload’
/usr/bin/rake:19

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