I have not gotten into exactly why it doesn't work but I can share with you a work around.
First, here is the code that will fail:
/project/app/models/financial/budget.rb
class Financial::Budget < ActiveRecord::BaseHowever, we found that having the has_many extend a module still works:
has_many :charge_sets do
def by_category
self.group_by(:category)
end
end
end
class Financial::Budget < ActiveRecord::Base
module ByCategory
def by_category
self.group_by(&:category) # group_by in the array of arrays sense *not* the sql sense
end
end
has_many :charge_sets, :extend => ByCategory
end
BTW, my coworker has a great blog that I have found useful in the past perhaps you will too!
Avdi Grimm http://avdi.org/devblog/
0 comments:
Post a Comment