How to name a enum with the name being different from its name in a database?
Asked Answered
A

0

6

I have a model with enum:

class MyModel < ApplicationRecord
  enum my_enum: [:status1, :status2, :status3, :status4]


  # .........
end

I want to field in the database to be titled "status", whereas in my model it should be titled "my_enum"

Is this possible? How to specify the name of the source column in database?

I'm aware of "_prefix", "postfix" properties of "enum" in Rails and this isn't what I need.

Auxin answered 24/10, 2018 at 22:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.