Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Adds support for enumerable types to ActiveRecord
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
README.rdoc
init.rb

README.rdoc

active-record-enumerable

Installation

script/plugin install git://github.com/ddollar/active-record-enumerable.git

Usage

class Food < ActiveRecord::Base
  include ActiveRecordEnumerable

  enumerate :type,  :as => %w( fruit vegetable ), :default => 'fruit'
  enumerate :color, :as => %w( red green )
end

Example

>> f = Food.new
=> #<Food id: nil, type: "foo", color: "red">
>> f.save
=> true

>> f.color.red?
=> true

>> f.color.turquoise?
=> false

>> f.update_attributes!(:color => "random")
=> ActiveRecord::RecordInvalid: Validation failed: Color is not included in the list

MIT License

Something went wrong with that request. Please try again.