I am upgrading a rails app from 3.0.20 to 3.2.13. It seems that when my test environment has cache_classes set to true the models are getting loaded before the initializers. This is causing some errors since my initializers have some setup code for some of the models. What is also strange is that in production with cache_classes=true, I do not experience the same issue. Could anyone point me in the right direction here.
Try adding this to your config/environments/test.rb file. It will load your intializers before the classes are cached:
# Load initializers before models get cached
config.before_eager_load do
Dir[File.expand_path "../../initializers/*", __FILE__].each { |file| require file }
end
Alternatively, you might check to make sure that you don't have a gem that is loading the models before the initializers are being called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With