optional null: false in tables for rails code example
Example: rails g migration foreign key optionnal
#MODEL
belongs_to :author, optional: true
#MIGRATION
t.references :author, foreign_key: true
#MODEL
belongs_to :author, optional: true
#MIGRATION
t.references :author, foreign_key: true