How to store enum as string to database in rails

前端 未结 5 1080
广开言路
广开言路 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:29

    Take a look at this Gist, Rails doesn't provide it out of the box so you have to use a concern:

    https://gist.github.com/mani47/86096220ccd06fe46f0c09306e9d382d

提交回复
热议问题