Module: ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnMethods

Defined in:
lib/enum_kit/active_record_patches/connection_adapters/postgresql/column_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#enum(name, options = {}) ⇒ Object

Create an enum column with the provided name.

By default, the enum type will match the name of the column. You can change this behaviour by providing the enum type as an option under the ‘:enum_type` key.

Examples:

Creating a user role.

t.enum :role, enum_type: :user_role


26
27
28
# File 'lib/enum_kit/active_record_patches/connection_adapters/postgresql/column_methods.rb', line 26

def enum(name, options = {})
  column(name, options[:enum_type] || name, options.except(:enum_type))
end