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.
In config/application.rb
, 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.
You need to add a 'require' (on application.rb) with your classes inside the lib folder.
Like:
require './lib/someclass'
I recommend you put it inside a Rails plugin.
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