0

I am new to both Ruby and Rails.

I'm using AASM to put state machine behavior into a model class. Depending on the old and new states I want to handle the state change event in different ways.

How do I either invoke the "after" callback with the "to" and "from" states as arguments or access the internal fields of held by AASM if those have what I need? ...or do I just have to add both before and after callbacks and save the previous state in the before callback?

mattx
  • 235
  • 1
  • 10

1 Answers1

0

You can access ModelClass.aasm_state()

If you have different transitions for different states.

Aasm is pretty well documented. You can find the instructions in the README for aasm: https://github.com/rubyist/aasm

state :dating,   :enter => :make_happy,        :exit => :make_depressed

def make_happy
  # do something
end

...
sunkencity
  • 3,382
  • 1
  • 18
  • 18