Generate Rails models with mandatory/required fields (i.e not null) from command line

后端 未结 1 1561
离开以前
离开以前 2021-02-05 07:23

Can anyone please help with generating Rails models with mandatory fields/columns (i.e. NOT NULL)? For example,

$rails generate model Role name:string 

        
1条回答
  •  旧时难觅i
    2021-02-05 07:58

    You can't do that in a generator command. It's quite simple to add null: false to your migration file though.

    0 讨论(0)
提交回复
热议问题