Acts_as_state_machine

Hi,

I want to use the acts_as_state_machine for work flow.
Please let me know how to use this.

Can you please give one example.

Thank you,
srinivasrao.pala

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
a :guard=>xxx to the transition (xxx= a Proc or a method name).
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

On Apr 1, 11:27 pm, Srinu P. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs