Reputation: 412
Today, we are able to get fields type for a lambda class by doing : User.columns.map { |c| [c.name, c.type]}
If a field is an enum, it will return the type integer
. Is there anyway to find which fields are set as an enum from an active record class?
Upvotes: 1
Views: 1932
Reputation: 2620
User.columns.map { |c| [c.name, c.type, User.defined_enums[c.name]].compact }
Upvotes: 0
Reputation: 5552
You can get it as (provided by ActiveRecord::Enum
),
User.defined_enums.keys
Upvotes: 8