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
View this message in context:
http://www.nabble.com/empty-emtry-in-database-problem-tp18193221p18193221.html
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
Hi
In migration file you can speciy like
:null => true
If false, the underlying column has a not null constraint added (if the
database supports it).
You can use like
t.column :name_last, :string, :null=>true (for example)
And already migration file exists you can change column type using
change_column
Sijo
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??
sorry but that i alreayd tried… not working … still saving a field as
empty in database.!!
On Mon, Jun 30, 2008 at 5:28 PM, Sijo Kg
[email protected]
On 30 Jun 2008, at 14:15, supriya agarwal wrote:
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