Hi.
In this setup "account has_many :consultations". Can anyone explain the following behaviour to me? Rails 1.2.2. The "sum" method should return 0 for an empty array.
a = Account.find(1)
=> #<Account:0x39c80a8 @attributes={...}
a.consultations
=>
a.consultations.sum(&:foo)
ArgumentError: wrong number of arguments (1 for 2) from ./script/../config/../config/../vendor/rails/activerecord/ lib/active_record/associations/has_many_through_association.rb:110:in `calculate' from ./script/../config/../config/../vendor/rails/activerecord/ lib/active_record/associations/has_many_through_association.rb:110:in `send' from ./script/../config/../config/../vendor/rails/activerecord/ lib/active_record/associations/has_many_through_association.rb:110:in `method_missing' from ./script/../config/../config/../vendor/rails/activerecord/ lib/active_record/base.rb:946:in `with_scope' from ./script/../config/../config/../vendor/rails/activerecord/ lib/active_record/associations/has_many_through_association.rb:110:in `method_missing' from ./script/../config/../config/../vendor/rails/activerecord/ lib/active_record/associations/has_many_through_association.rb:102:in `sum' from (irb):15
But if I use a hard coded empty array, things work:
.sum(&:foo)
=> 0
What's happening? Thanks.
Morten