How to store enum as string to database in rails

前端 未结 5 1147
广开言路
广开言路 2021-02-05 07:46

How do I create a migration in ruby where the default is a string rather than an Integer, I want to store enum into the database, but I do not want to store it as Integer, becau

5条回答
  •  半阙折子戏
    2021-02-05 08:15

    To my knowledge it is not possible with standard Rails enum. Look at https://github.com/lwe/simple_enum, it is more functionally rich, and also allows storing of enum values as strings to DB (column type string, i.e. varchar in terms of DB).

提交回复
热议问题