Automatically populating models with the defaults from the table definition

I am using SQL server with ODBC adapter. If I have a field defined as
“hair_color string(255) default(“UNK”), not null” it causes
problems with saving the record if I don’t specify the hair color.

In this case if I don’t specify a hair color AR puts a NULL into the
insert clause and SQL server pukes. If AR simply had left that field
out of the insert everything would have been fine.

Is there a way to tell AR to either leave the NULL fields out of the
insert (or update) or to load the defaults into the model when it’s


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs