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.
我不记得从 rails 控制台检索保存在数据库中的所有无效对象的原因很简单。
知道怎么做吗?
假设您的模型称为 Widget,则:
Widget.all.select(&:invalid?)
如果您有大量数据,这可能会非常慢,但是如果您想检查它们的有效性,则必须从数据库中检索记录。