Re: ActiveRecord uses confusing defaults

Jeroen
Sun, 10 Sep 2006 09:08:21 -0000

John Higgins wrote:
> Jeroen,
>
> You aren''t going nuts - it''s just AR trying to make
it''s best
> interpretation
> of what it gets and this may very well be an edge case that could be up
> for
> discussion.
[...]
> Hope this helps you understand how it works and why
>
> John W Higgins


Thanks for the explenations John / Al. I think the biggest thing for me
is that it''s counter untuitive (for me) when it comes to validations.
When you have validates_presence_of on NOT NULL columns the default
newly created AR model will pass through these validations, because the
AR defaults are there (0 for instance). But when you do the same on a
column that *can* be NULL the same validatons will fail because the AR
defaults are nil. What I could do is care even less about the database
and make every column nullable and hope my AR rules will prevent NULLS
from being saved, but that doesn''t sit right with me really.

Jeroen