namespace :test_db do
task validate_all_objects: :environment do
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each do |file|
begin
require file
rescue
end
end
ActiveRecord::Base.descendants.each do |model|
print model
print "\n"
begin
array = model.try(:all)
array.each do |object|
unless object.valid?
print object.id
print ' : '
print object.errors.to_json
print "\n"
end
end
rescue
end
print "\n"
end
end
end