Get all objects with errors from the model on ActiveRecord

Itโ€™s easy to understand why I donโ€™t remember to recover all invalid objects stored in the database from the rails console.

Any idea how?

+4
source share
1 answer

say your model is called Widget, and then:

Widget.all.select(&:invalid?) 

This is probably very slow if you have a lot of data, but you must retrieve the records from the database if you want to verify their authenticity.

+12
source

Source: https://habr.com/ru/post/1413366/


All Articles