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 Pala
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---