I have a class located inside RAILS_ROOT/lib folder, which I use in one of my helpers, and it works great in development.
When I switch to production, the applicati
When you call SomeHelper::SomeClass, Rails' autoloading mechanism will try to load file at lib/some_helper/some_class.rb
Rails won't load everything in lib/*, it will only try to load files when ConstMissing occurs.
You might need to check differences between the configuration settings between development and production environment:
config/environments/production.rb
and config/environments/development.rb
.
During the Rails initialization routine, load_plugins()
is called which loads all plugins in config.plugin_paths
. You need to make sure that your folder lib/
is included, like in
config.plugin_paths = ["#{RAILS_ROOT}/lib/plugins", "#{RAILS_ROOT}/vendor/plugins"]
In addition to config.plugin_paths
, you can also name the plugins that should be loaded in config.plugins
. If that variable contains :all
then all plugins (found) will be loaded.
(By the way: configuration settings equal to either environment should go in config/environment.rb
. Any differences between enviroments are due to settings in the respective .rb
files.)