我正在开发 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)])