removing the www before a domain with Rails3?

Hello, In Rails2 I used a middleware to redirect www.mydomain.tld to mydomain.tld. Something like this: It is in Libs, with filename "no_www.rb". I tryed to add as the first line of environment.rb as suggested in here: Rails on Rack — Ruby on Rails Guides

When it failed l put it in application,rb, the first line after class Application < Rails::Application in application.rb is: config.middleware.use "NoWWW" But when I try to run the app I get: C:/Ruby/lib/ruby/gems/1.9.1/gems/ activesupport-3.0.0.rc2/lib/active_support/inflector/methods.rb:124:in `block in constantize': uninitialized constant NoWWW (NameError)

Any idea how to use it? Unfortunately I can't use mod_rewrite, since I plan to put the app. on Heroku.

I have found the solution. The config.middleware.use should be put into application.rb, and the / lib is no longer loaded automatically so you need to load it, like this:

  class Application < Rails::Application     config.autoload_paths += %W(#{Rails.root}/lib)     config.middleware.use "NoWWW"     ...

Hope this helps someone.