简体   繁体   中英

Store strings with special characters as enum values in Rails 5

In Rails 5, the enum value type can only accept symbols, ie immutable "strings" with letters and digits.

How would you best use enum values in Rails, which have to be shown also with their special characters like eg 'Hip-Hop/Rap' included in the enum field genre ?

如果符号文本包含特殊字符,则可以在符号文本周围使用引号。

[:classical, :pop, :'Hip-Hop/Rap']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM