ddollar / active-record-enumerable
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
README.rdoc | ||
| |
init.rb | ||
| |
lib/ |
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

