ruby on rails - uninitialized - Rails 5 ignoring/lib class?




reload class rails (2)

I've used this method for modals in rails. It works really well, but I've just upgraded to Rails 5 beta3, and now it's not working in production.

I get this error:

Completed 500 Internal Server Error in 22ms (ActiveRecord: 0.9ms)

NameError (uninitialized constant ApplicationController::ModalResponder):

app/controllers/application_controller.rb:26:in `respond_modal_with'
app/controllers/tools_controller.rb:28:in `new'

Is my inheritance thrown off with Rails 5?

My class ModalResponder < ActionController::Responder is in /lib and works in development...

Looking for info on changes with rails 5, but sources are limited to my knowledge.


It says it cannot find the ApplicationController::Responder which was moved out of Rails 4.2 into a separate gem.

Add gem 'responders' to your Gemfile

Classes in lib are not autoloaded, you have to require them


Change this:

config.autoload_paths << Rails.root.join('lib')

to this:

config.eager_load_paths << Rails.root.join('lib')

eager_load_paths will get eagerly loaded in production and on-demand in development. Doing it this way, you don't need to require every file explicitly.

See more info on this answer.





ruby-on-rails-5