Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 TODO
Octocat-spinner-32 init.rb
README
= Acts As State Machine

This act gives an Active Record model the ability to act as a finite state
machine (FSM).

Acquire via subversion at:

http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk

If prompted, use the user/pass anonymous/anonymous.

== Example

 class Order < ActiveRecord::Base
   acts_as_state_machine :initial => :opened

   state :opened
   state :closed, :enter => Proc.new {|o| Mailer.send_notice(o)}
   state :returned

   event :close do
     transitions :to => :closed, :from => :opened
   end

   event :return do
     transitions :to => :returned, :from => :closed
   end
 end

 o = Order.create
 o.close! # notice is sent by mailer
 o.return!

This version of State Machine will additionally create named scopes for your states - referring to the above example

Order.opened will return all orders with a state of opened
Order.closed will return all models with a state of closed

and so on 

For more information on named scopes see 
http://railscasts.com/episodes/108
Something went wrong with that request. Please try again.