Friday, August 24, 2012

Rails 3.2 Rack install


As of Rails 3.2, Rack middleware belongs in the app/middleware directory.
It works "out-of-the-box" without any explicit require statements.
Quick example:
I'm using a middleware class called CanonicalHost which is implemented inapp/middleware/canonical_host.rb. I've added the following line to production.rb (note that the middleware class is explicitly given, rather than as a quoted string):
config.middleware.use CanonicalHost, "example.com"
This works as desired.