empty emtry in database problem

Hi,

While adding a new entry in my database , if i dnt enter one of the field, it gets stored as emtry string and not as NULL field.This creates some problem while searching on that model. How can i deal with it??

Thanks, Sup

sorry but that i alreayd tried… not working … still saving a field as empty in database.!! :frowning:

You are probably setting the attribute to an empty string before saving the record/model instance. How is the attribute being populated?

Empty string is still valid (not null)...

im not setting it anywhere, it is just getting added through basic code of:

@device = Dev.new(@params[:dev]) and after that checking @device.save and then redirecting_to some page.

if im not entering anything nothing gets added. my point is it shud get added as NULL in database. should’nt it??

im not setting it anywhere, it is just getting added through basic
code of:

@device = Dev.new(@params[:dev]) and after that checking @device.save and then redirecting_to some
page.

if im not entering anything nothing gets added. my point is it shud
get added as NULL in database. should'nt it??

By nothing do you mean that there is a corresponding text field which
you have left empty? That will submit an empty string. If you want to coerce those to nulls you'll have to do it yourself

Fred