sql validations
Dear Rails developers,
Please don’t use sql validations, like null false or length 3.
These are a huge hassle, as they add a layer to activerecord validations that becomes surprising 3 months later.
They are also annoying to get rid of.
That user_id that you thought HAD to be there (so you set null false) might turn out 3 months from now to be non-required, and then whoever is maintaining the code gets a sql error, and then they have to change the column and it’s waste of time. Just use validates_presence_of.
Maybe there is a speed issue, but this is 99% of the time not the case.
December 19, 2008
