How To Use Enums in Rails 6

An enum is a data type made out of a set of named values. Let’s leverage them

Catalin Ionescu
Better Programming
Published in
3 min readMar 18, 2021

--

Text on yellow background
How to use enums in Ruby on Rails. Photo by the author.

In Ruby on Rails, an enum is an attribute where the values map to integers in the database and can be queried by name.

For example, we could define an enum for the status attribute, where the possible values are pending, active, or archived.

--

--