Reputation: 1165
I have been using aasm gem (https://github.com/aasm/aasm) to define an object. It comes with several public method for events. For example:
With object a_machine
, event boot_up
would transit the object to a new state greeting
. I would be able to do the following query: a_machine.may_boot_up?
. However, I change the name boot_up
to wake_up
. Now the following method throws an exception:
a_machine.aasm.events(permitted: true)
# undefined method: may_boot_up?
I would like to ask how permitted
is implemented because it still has an outdated public method (associated with an outdated event name).
Other things work fine. Does anyone know why? Or can you please give me further instruction on how to proceed? Thank you,
EDIT: I have more clue:
After i change the name of the event :boot_up
to :wake_up
, what actually happens is that the symbol :boot_up
still stays in the event array, and a new symbol :wake_up
is added to that array. a_machine.aasm.events.map(&:name)
returns the event array.
UPDATE: Now the question is framed as: how to remove an event from AASM::Core::Event because the :boot_up
was added as an event and by changing the name I accidentally only add a new event :wake_up
.
Upvotes: 0
Views: 630
Reputation: 1600
You will need to restart your rails console/server once you have made changes to the state machine events.
Upvotes: 1