Statusable
Allows for using a status column, rather than inheriting Enumberable or using a mapping table
Basic Use
class Invite < ActiveRecord::Base
include Statusable
# define the statuses of this model
has_statuses :pending => 0,
:queued => 1,
:declined => 2,
:spam => 3,
:delivered => 4,
:accepted => 5
end
Features
- named_scopes for each status
- boolean instance methods to check for statuses
- assignment of status based on symbol or integer value
Examples
# named_scopes
Invite.pending
=> returns all pending invites (invites with status 0)
i = Invite.new
# assignment by symbol, or integer
i.status = :queued
i.status = 5
# boolean status methods
i.pending?
=> false
i.accepted
=> true
# get all the statuses
Invite.statuses
=> {:pending=>0, :queued=>1, :declined=>2, :spam=>3, :delivered=>4, :accepted=>5}
# get the value of a status
Invite.statuses[:accepted]
=> 5
Support
I have no plans to ‘continue’ development on this, it does what I need it to do at this time. If you would like to extend it, turn it into a plugin, go to town..
Credit
This code (most of it remains, I’ve just added to it) is based of a pastebin I found by Marcello Barnaba located here.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
