acts_as_state_machine

Check the example here: http://agilewebdevelopment.com/plugins/acts_as_state_machine

It's fairly straightforward. First, you declare the acceptable 'states' for the object. aasm assumes that you will have an initial state called 'initial' and that the state is stored in a column named 'state' but you can override both of those conventions.

Next you declare the permissible 'transitions' that change the object from one state to another. If the transition from state X=>Y should occur only if certain other conditions are met then you can add Similarly you can specify :exit and :enter methods that should be executed when the transition is followed.

Finally, you use the transitions in your business logic. Referring to the link posted above, you would trigger the :accept transition on and instance of the Nonprofit with some code like this:

@nonprofit = Nonprofit.find params[:id] @nonprofit.accept! #Note that the transition has given you a !-method with the same name