Module: ActiveRecord::PGEnum::CreateEnum
- Defined in:
- lib/active_record/pg_enum/6.1/create_enum.rb
Instance Method Summary collapse
-
#create_enum(name, values) ⇒ Object
Create a new ENUM type, with an arbitrary number of values.
Instance Method Details
#create_enum(name, values) ⇒ Object
Create a new ENUM type, with an arbitrary number of values.
Example:
create_enum("foo_type", "foo", "bar", "baz", "foo bar")
14 15 16 17 18 |
# File 'lib/active_record/pg_enum/6.1/create_enum.rb', line 14 def create_enum(name, values) execute("CREATE TYPE #{name} AS ENUM (#{Array(values).map { |v| "'#{v}'" }.join(", ")})").tap { reload_type_map } end |