Ruby on Rails ActiveRecord query to find single lines -
modela has_many modelb, , want find of modela have 1 modelb. came with
modelb.select('modela_id').group('modela_id').count
to number of occurence of each one, there nice ruby way list of modela_id count 1? or better way beginning?
try using having clause
modelb.select('modela_id').group('modela_id').having('count(modela_id) = ?', 1)
Comments
Post a Comment