Rails Rails 6.1 allows enums attributes to configure the default value

lidashuang · July 22, 2020 · 1709 hits
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

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.