We are currently building a new product on Rails 3 with a couple custom middleware rack apps. Everything is working great on development and we’re progressing nicely. Today I decided to start setting up the production environment and the following error popped up:
No such middleware to insert after: "ActionDispatch::Static"
I had this in my config/application.rb:
I received this error while trying to run rake or startup unicorn. After looking around trying to figure out what I was doing wrong I discovered this in the production config.
config.serve_static_assets = false
Essentially what this does is remove “ActionDispatch::Static” from the rails middleware stack. I had no idea that I could not rely on that being there.
Solution, use insert_before ‘Rack::Lock’ instead:
Hope this saves someone some time!