Antares Trader Blog

The universe at your fingertips

No cattr_accessor Blame Rails 3

Sunday

Feb 14, 2010

3:48 pm

Here is another one of those head scratching moments that makes a lot of sense once you know what is going on. If you have installed the Rails 3 pre release, you may have inadvertently broken a number of gems that depend on ActiveSupport.

I've been putting MongoMapper through its paces. John Nunemaker has done an awesome job on this thing, but it's still very rough and lacking documentation. Last night, while I couldn't sleep due to a sour stomach, I was starting to write an adapter for MongoMapper to go with my Updater gem. Every time I tried to include MongoMapper::Document all hell broke loose. I'd see errors like NoMethodError: undefined methodcattr_accessor'` and when I check this method was indeed missing.

The answer to all this is that ActiveSupport is used ubiquitously by everyone, and in Rails 3 it has changed (apparently a lot). When I installed Rails 3 I broke everything that depended on ActiveSupprot 2.3.X. The fast fix is to add the line

 gem "active_support" "2.3.5"

after requiring rubygems. The longer term solution is to seperate out incompatible gems using rvm. Here is the documentation on how to do exactly that.

As an aside, I find it interesting that there are so many projects that use ActiveSupport. I prefer extlib only because it is already loaded by some of my favorite gems such as DataMapper and Merb. Never the less gems liek these are becoming the stdlib or ruby and to make major changes to on is going to come as quite a shock to a lot of developers.

edit delete