When do we need to use AASM

I am searching AASM gem to apply my demo project but I am wondering when
I
really need to use it and use it in what case? What is advantages and
disadvantages?

So if someone has experiences on it, could you tell me know.

Best regards,

Hi,

Its a state management gem usually used in ecommerce . I’ve used them in
healthcare products and social networking.

Ecommerce - Cart status : new , order_placed, :shipped,
feedback_provided
Healthcare - Bed status : new, has_patient, :patiend_discharged,
patient_billed
Social networking - Friendship , :friends, :request_sent,
:request_accepted, :request_rejected,

Cheers
Vivek

On Fri, Jan 9, 2015 at 9:44 AM, hai nguyen ngoc <

Although I do see it work well in some cases, I also see state machine
implemented badly in other cases. In particular, I find that it
encourages an over-use an over-reliance on the callback hook pattern (in
the context of AASM, attaching methods to specific transitions).

In smaller implementations it can work well, but as the complexity of
domain logic grows it often breaks down and leads to difficult to debug
code (and smelly code).

So with all things Rails, your mileage may vary. I would suggest reading
up on DCI and thinking about how it might look to build an object (in
the context of DCI, this is called a “context object”) that represented
all the things the state transition does itself. For example, if you
were going to ship a shipment, you would want to 1) change its state, 2)
mark it shipped_at, 3) send an email, 4) etc, etc.

The idea behind DCI is that we consider the transition itself to be
domain knowledge and give it a first-order class (although certainly not
an Activerecord object) in our app. That’s the basic gist of it. It is
also possible to use a state machine pattern alongside DCI or DCI-like
patterns. I think the questions is, how much do you use State machine
and how much do you rely on attaching hooks to your transitions.

-Jason


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected]alid
mailto:[email protected].
To post to this group, send email to [email protected]
mailto:[email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/d26c47d3-54e5-4fe4-b461-52b82bc21f92%40googlegroups.com
https://groups.google.com/d/msgid/rubyonrails-talk/d26c47d3-54e5-4fe4-b461-52b82bc21f92%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout
https://groups.google.com/d/optout.


Jason Fleetwood-Boldt
[email protected]
http://www.jasonfleetwoodboldt.com/writing

All material © Jason Fleetwood-Boldt 2014. Public conversations may be
turned into blog posts (original poster information will be made
anonymous). Email [email protected] with questions/concerns about
this.