Q:

Enumerate a enum

I have a enum:
class Model1 < ActiveRecord::Base
  enum enum1: [:var1, :var2, :var3]
end

How can I enumerate enum1 to get all the values of enum1 which are [var1, var2, var3]?

A:

The simplest option is to not do anything with the enum, but rather extract that static array to a constant
class Model1 < ActiveRecord::Base
  ENUM_OPTIONS = [:var1, :var2, :var3]

  enum enum1: ENUM_OPTIONS
end

Then you'll be able to do Model1::ENUM_OPTIONS

