rails g migration foreign key optifnnal 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