Rails 2.3.8 Ruby 1.8.7 および PostgreSQL を開発しています。
特定のサイズ以下のモデルを検索したいのですが、検索条件の書き方は?
たとえば、コメントが 5 件未満のトピックを検索したいとします。
class Topic < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :topic
end
Topic.find(:all,:include => :comments, :conditions => [(which has less than 5 comments)])