public
Description: Adds support for declaring an ActiveRecord class as an enumeration
Homepage: http://www.pluginaweek.org
Clone URL: git://github.com/pluginaweek/enumerate_by.git
name age message
file CHANGELOG Loading commit data...
file MIT-LICENSE Sun May 04 14:35:16 -0700 2008 Move to trunk Add support for overriding the un... [obrie]
file README
file Rakefile
file init.rb Thu Jul 12 11:28:04 -0700 2007 Initial release [obrie]
directory lib/
directory test/ Sun Jun 22 10:54:20 -0700 2008 Improve performance by disabling unnecessary Ac... [obrie]
README
= acts_as_enumeration

+acts_as_enumeration+ adds support for declaring an ActiveRecord class as an
enumeration.

== Resources

Wiki

* http://wiki.pluginaweek.org/Acts_as_enumeration

API

* http://api.pluginaweek.org/acts_as_enumeration

Development

* http://dev.pluginaweek.org/browser/trunk/acts_as_enumeration

Source

* http://svn.pluginaweek.org/trunk/acts_as_enumeration

== Description

Support for enumerations is dependent on the type of database you use.  For
example, MySQL has native support for the enum data type.  However, there is
no native Rails support for defining enumerations and the associations between
it and other models in the application.

acts_as_enumeration adds support for enumerations in Rails by providing methods
for interacting with records in a table as if they were values in an
enumeration.

== Usage

=== Single-dimensional enumeration

  class Color < ActiveRecord::Base
    acts_as_enumeration
    
    create :id => 1, :name => 'red'
    create :id => 2, :name => 'blue'
    create :id => 3, :name => 'green'
  end

=== Customized enumeration

  class Book < ActiveRecord::Base
    acts_as_enumeration :title
    
    create :id => 1, :title => 'Blink'
  end

== Future development

See acts_as_enumeration_in_memory[http://wiki.pluginaweek.org/Acts_as_enumeration_in_memory]
for more information about the future development of this plugin in terms of
ease of maintenance and utilization of ActiveRecord.  acts_as_enumeration_in_memory
is an experimental re-implementation of this plugin using an in-memory SQLite3
database.

== Testing

Before you can run any tests, the following gem must be installed:
* plugin_test_helper[http://wiki.pluginaweek.org/Plugin_test_helper]

To run against a specific version of Rails:

  rake test RAILS_FRAMEWORK_ROOT=/path/to/rails

== Dependencies

* Rails 2.1 or later

== References

* Trevor Squires - enumerations_mixin[http://svn.protocool.com/rails/plugins/enumerations_mixin]