MySQL allows the value of 0000-00-00 for date fields, however ActiveRecord treats an assignment to a Date value with that string as being nil.
I have a legacy application that relies on that exact field content for the notion of “Never”, so if the customer last payment date is 0000-00-00 it acknowledges as being “Never” paid.
Is there a way I can override ActiveRecord (correct) validation for this date field and write this value to the database without getting my hands (too) dirty?
Thanks for any insight.
You may find this slightly easier and it should achieve the same result without executing the method for every attribute in the model
You could of course refactor the code to call read_attribute twice and do the lastpaid method as a one-liner. It’s a matter of style/minute performance differences really.