Reputation: 2569
In rails migrations what is the difference between null: false
and required: true
?
For eg. if I write:
t.string :phone_number, required: true
is it same as:
t.string :phone_number, null: false
If both are different then how exactly do they differ?
Thanks in advance:)
Upvotes: 3
Views: 2948
Reputation: 228
required:true
doesn't do anything in migrations. Are you perhaps getting confused with Active Record Validations?
TL;DR: Use null:false
.
Upvotes: 5