table_warnings

NOTE: only for activerecord right now because it uses count(:conditions => [...])

How to define warning signs

class AutomobileMake < ActiveRecord::Base
  warn_if_blanks :name
  warn_if_blanks :fuel_efficiency
  warn_unless_size :hundreds
end

How to see warnings for the table

?> AutomobileMake.table_warnings
=> [ "Table is not of expected size" ]

Defense

  • This is not the same as validations, because those interfere with the saving of individual records

Self-criticism

  • Maybe this should work work on any class that defines .all

Copyright 2011 Seamus Abshere