这可能需要一些实验,但答案是肯定的。以下代码可以作为起点:
User.find_each do |user|
untitled_topic_count = user.topics.where(title: "").count
titled_topic_count = user.topics.where.not(title: "").count
if untitled_topic_count > 0 && titled_topic_count == 0
# 删除主题和/或用户
end
end