I have this tiny bit of code, used in a few model classes in an application:
validates_format_of :month, :with => /\d{4}\/(0[1-9]|1[0-2])/i, :message => "must be in the format YYYY/MM"
What’s the rails way to DRY this up? i.e., where should the code go and how should it be called?
take a look at Active Model Validator