Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
PostgreSQL enumerated types in ActiveRecord
Ruby
tree: ef1c671239

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.document
.gitignore
.rspec
Gemfile
Gemfile.lock
LICENSE
README.textile
Rakefile
VERSION
enum_type.gemspec

README.textile

enum_type — Enumerated Types in ActiveRecord

Author Tim Morgan
Version 2.1 (May 14, 2012)
License Released under the MIT license.

About

enum_type allows you to effectively use the PostgreSQL ENUM data type in
your ActiveRecord models. It’s a really simple gem that just adds a convenience
method to take care of the usual “witch chant” that accompanies building an
enumerated type in Rails.

Installation

Important Note: This gem requires Ruby 1.9. Ruby 1.8 is not supported, and
will never be.

First, add the enum_type gem to your Gemfile:


gem 'enum_type'

Then, extend your model with the EnumType module:


class MyModel < ActiveRecord::Base
  extend EnumType
end

Usage

In your model, call the enum_type method, providing one or more enumerated
fields, and any additional options:


class MyModel < ActiveRecord::Base
  extend EnumType
  enum_type :status, %w( active pending admin superadmin banned )
end

See the {EnumType#enum_type} method documentation for more information.

Something went wrong with that request. Please try again.