ruby on rails - Is there a Gem that checks that all DB records are valid? -
when adding validations, it's easy make data in db invalid.
is there gem validates data in db?
it should easy load records , see if they're valid, if exists don't want reinvent it.
not sure if there gem it's not common case have invalid records. can understand may want if imported lot of data without validation or created validations after records created.
i rake task. depending on size of db can expensive.
namespace :validate desc "validates records" task :check_all_records # records module.constants.select { |c| (eval c).is_a? class }.each |class| # load 1000 memory @ time , check if they're valid class.find_each{ |record| fix_the_record_method unless record.valid? } end end end
Comments
Post a Comment