Everybody using Rails probably knows that ActiveRecord provides many methods for declaring validation of records – the validate method as well as validates_xxx methods which generate code for most common validation tasks. There is a problem though…
The validation can be easily skipped. Just use the update_attribute method and you can set any values without validation. Kinda scary if you’re used to encapsulating consistency checks in model – some other coder writing controllers for your model can just break your rules…
Just one more reason to ignore DHH’s words on moving validation to application layer and putting it back in database (where it should always be, even if you have the rules in your application layer too; skip consistency checks provided by the RDBMS only if they are too complicated to be effectively expressed with SQL or you’re using RDBMS with limited capabilites in this regard, like MySQL or SQLite)