Rails 3: How to declare rack middleware in application.rb

Many examples, such as these two:

How to use rack middleware with Rails3?

http://asciicasts.com/episodes/151-rack-middleware

define middleware in the class and then add

config.middleware.use "ClassNameHere" 

to config/application.rb , but I can't figure out where to add this in application.rb. I put it inside the class Application < Rails::Application . I'm also not sure if there is a specific place where I put my middleware class. I have my / lib.

Say my middleware class is called ResponseTimer, I get the following error when starting rake middleware : uninitialized constant ResponseTimer

Note that I'm in Rails 3.1, not 2.x, so I don't put config.middleware.use in environment.rb

+2
Jul 13 2018-12-12T00:
source share
1 answer

add config.autoload_paths += %W(#{config.root}/lib) to config/application.rb See here https://github.com/radar/guides/blob/master/rails-lib-files.md

+4
Jul 14 '12 at 5:12
source share
— -



All Articles