Disable ActiveRecord in Rails 3

Came up against this recently when trying to upgrade a Rails app which was using MongoDB. Obviously I didn't want to use ActiveRecord, so I set about removing it.

The old way of removing ActiveRecord was to place this line in the environment.rb file, "config.frameworks -= [ :active_record ]". However, in Rails 3 you can simply pass the "-O" switch to the rails command, like so:-

rails yourapp -O

But what if you've already created your app? If you look in your config/application.rb file, you'll see this line at the top:-

require 'rails/all'

This does what it says on the tin; includes all rails modules. If you want to exclude ActiveRecord, remove the above line and replace it with:-