Permanent fix for Rails’ wretched deprecation warning

Developing rails apps under Ubuntu means that we get a lot of these warnings:

DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from  at /usr/lib/ruby/vendor_ruby/activerecord.rb:2)

Recently, we added a cron job to an app which meant that we were getting emailed this error every hour, instead of just seeing it on the terminal. There’s really nothing like spam that’s your own fault to motivate a fix.

The problem wasn’t too hard to track down — the orm_adapter gem, which is used by active record, was attempting to include the old version of activerecord for backwards compatibility. But the last version of Rails that used the old version of active record was 2.3 (ish) so there was really no need anymore.

We forked, fixed, and the maintainer’s already merged. Not sure what the release date for a new gem is though!

In the meantime, if this is driving you crazy, you can get rid of the deprecation warning by editing /usr/lib/ruby/vendor_ruby/activerecord.rb:

require 'active_record'
ActiveSupport::Deprecation.warn 'require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead.'

Just comment out that second line, or, if you prefer, delete the file. (You might be able to edit orm_adapter in your production environment instead, but we couldn’t, because it gets reinstalled every time we deploy.)