Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
不知道有没有人遇到过这个问题:
当我这样做Question.count时,它返回3112,但是当我运行时Question.ids.count,结果是9685。
Question.count
Question.ids.count
我的数据库坏了吗?
好吧,当您在查询中包含孩子时,似乎这些 id 也会与结果一起出现。我有default_scope { includes(:choices) },我删除了它,一切正常。
default_scope { includes(:choices) }