Reputation: 927
Every time a controller or model tries to access a class on the /lib folder it says:
NameError (uninitialized constant 'current_controller':'class_name' did you mean 'something_else')
YES, I know the rails naming conventions and I am using it correctly. I have the code running in several other servers (Ubuntu & CentOS 6). It errors only on these 2 RedHat7.2 servers we have - same exact ruby/rails/gems on all servers. The error occurs with any library file I try to use. SELinux is disabled.
Ruby version 2.3.3; Rails version 5.1.0 (same on all servers)
Anyone have any ideas? Rails is suppose to automatically load those class files.
Upvotes: 1
Views: 3189
Reputation: 2290
On rails < 5:
module your_app
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.autoload_paths += %W(#{config.root}/lib/path)
end
end
on rails >= 5
module your_app
class Application < Rails::Application
config.eager_load_paths << "#{Rails.root}/lib/path"
end
end
If you want rails to auto load your lib you have to place it under the app
folder.
Upvotes: 3