You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug aasm.from_state is empty for callbacks when the transition does not define from states. Not specifying from states is very useful when the state should be immediately reachable from any other state.
To Reproduce
Steps to reproduce the behavior:
Here's a small (untested) example that should get the idea across. The important thing is to include a transition with no from (transitions from any state) and a callback that will use aasm.from_state in response to that transition.
aasm do
state :awake, initial: true
state :tired
# other states...
after_all_transitions :log_status_change
event :coffee do
transitions to: :awake
end
event :party do
transitions to: :tired
end
end
def log_status_change
puts "changing from #{aasm.from_state} to #{aasm.to_state} (event: #{aasm.current_event})"
end
Expected behavior aasm.to_state is populated in all cases, but aasm.from_state is not populated for events like :coffee and :party in the above example.
The text was updated successfully, but these errors were encountered:
steamwings
changed the title
aasm.from_state is not always populatedaasm.from_state is not always populated
Dec 16, 2022
Describe the bug
aasm.from_state
is empty for callbacks when the transition does not definefrom
states. Not specifying from states is very useful when the state should be immediately reachable from any other state.To Reproduce
Steps to reproduce the behavior:
Here's a small (untested) example that should get the idea across. The important thing is to include a transition with no from (transitions from any state) and a callback that will use
aasm.from_state
in response to that transition.Expected behavior
aasm.to_state
is populated in all cases, butaasm.from_state
is not populated for events like:coffee
and:party
in the above example.The text was updated successfully, but these errors were encountered: