Forum: Ruby on Rails Relation null or zero?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
papipo (Guest)
on 2005-12-05 11:39
(Received via mailing list)
I was having some issues while testing one of my models. I added a
:before_add to a habtm relation, and the filter didn't work due to the
foreign key being initialized to zero, instead of NULL. I simply
supposed
that it should be being initialized with a nil value, but it seems that
this
depends on the database table schema.

Should i use NOT NULL or NULL with foreign keys? I really like the
NULL/nil
thing when the relation is not yet stablished, but in some cases this is
not
good since the relation must be present to the model to be valid. But we
have the :dependent clause.

Thanks,
Rodrigo.
This topic is locked and can not be replied to.