Radhika
Radhika

Reputation: 2569

Difference between null: false and required: true in rails

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

Answers (1)

Sam Morgan
Sam Morgan

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

Related Questions