Which is the difference between :null => true and :default => nil?
If a field is going to be optional, which option of those would be the
best?
t.string :optional, :null => true
or
t.string :optional, default => nil
Which is the difference between :null => true and :default => nil?
If a field is going to be optional, which option of those would be the
best?
t.string :optional, :null => true
or
t.string :optional, default => nil
On 6 Nov 2007, at 10:58, Kless wrote:
Which is the difference between :null => true and :default => nil?
:null => true/false is whether the column is not null or not. At least
on my version of mysql, the default is that null is allowed.
:default => nil says that the default value for the column is null
(which is the default).
If a field is going to be optional, which option of those would be the
best?
t.string :optional, :null => trueor
t.string :optional, default => nil
t.string :optional, :null => true corresponds to what you actually
want. You probably don’t need :null => true since I believe it’s the
default
Fred
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs