Rails Rails 6.1 allows enums attributes to configure the default value

lidashuang · 2020年07月22日 · 1707 次阅读
class Post < ApplicationRecord
  enum status: %i[draft reviewed published], _default: "draft"
  enum category: { rails: "Rails", react: "React" }, _default: "Rails"
end

https://blog.bigbinary.com/2020/07/21/rails-6-1-allows-enums-attributes-to-have-default-value.html

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号