I have a class in the lib directory: lib\db_cache.rb, that defines class DbCache.
My Rails model can access it when in dev mode and also when I run rails console in production mode.
But when I run the production mode rails server, the model class, eg Foo, complains about "uninitialized constant" Foo::DbCache,
org/jruby/RubyModule.java:2677:in `const_missing',
org/jruby/RubyMethod.java:134:in `call'
I have this line in application.rb
config.autoload_paths += %W(#{Rails.root}/lib)
I have also tried the other variations shown in the linked SO questions - but no joy.
I am using jruby 1.7.3 (1.9.3p385) - Java 1.7.0_13-b20, on linux. Rails is version 3.2.12.
I've seen these questions Rails - why would a model inside RAILS_ROOT/lib not be available in production mode? and Best way to load module/class from lib folder in Rails 3? but that doesnt seem to help my case.
Thanks in advance for any ideas on this.
PS My work-hack-around for now is to require 'db_cache' in my model class :(