This question is fairly similar to [1], except that I'm using Rails 2.3.5 (yes, old) and a complete newb at RoR. I have two models, Configfile and Signoff.
I want to find all Configfiles where the number of signoffs is < 2. Of course, I could do this by filtering the array manually, but this database is big and it's fairly slow.
class Configfile < ActiveRecord::Base
belongs_to :computer
has_many :signoffs,
:dependent => :destroy
end
and
class Signoff < ActiveRecord::Base
belongs_to :configfile
end
This seems like something that should be fairly easy to do in Rails, but I can't figure it out. My query looks like this so far, and I haven't gotten anything that works for limiting it by the number of signoffs.
configs = c.configfiles.find(:all,
:include => :signoffs,
:order => 'filename')