If you want to use the Classifier gem within a Rails project, you’re in for a surprise:

 1 /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:102:in `sum': wrong number of arguments (1 for 0) (ArgumentError)
 2         from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:102:in `instance_method_already_implemented?'
 3         from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:72:in `define_attribute_methods'
 4         from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:71:in `each'
 5         from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:71:in `define_attribute_methods'
 6         from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:351:in `respond_to?'
 7         from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:219:in `method_missing'
 8         from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:219:in `each'
 9         from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:219:in `send'
10         from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:219:in `method_missing'
11         from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:364:in `method_missing_without_paginate'
12         from /Users/francois/Projects/family_budget/vendor/gems/mislav-will_paginate-2.3.5/lib/will_paginate/finder.rb:167:in `method_missing'
13         from script/classifier:8

This is because the Classifier gem implements Array#sum. Unfortunately, Classifier is loaded after Rails, which means ActiveSupport’s own #sum is replaced. The solution? Use either Yury’s fork, or my own. Both use ActiveSupport’s #sum instead of a custom implementation.

The only difference between my version and Yury’s is I use Jeweler to maintain and package the gem.

Search

Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend

Links

Projects I work on

Projects I worked on