How does one add an attribute to a model?

后端 未结 4 675
余生分开走
余生分开走 2020-12-07 19:05

In rails I generate a model with two strings and would like to add more. How would I go about doing this?

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 19:19

    Yes, the solution by @JCorcuera is applicable, but I suggest applying a little more information to Rails to fulfill our requirement. Try this approach:

    rails generate migration add_columnname_to_tablename columnname:datatype
    

    For example:

    rails generate migration add_password_to_users password:string
    

提交回复
热议问题