1

I want to be able to utilize the acts_as_state_machine transition methods which are auto-generated (e.g. event!).. but I don't want it to save right away. I'm updating the state as part of another set of operations, and so I don't want to be doing double saves.

Is there any way to trigger these event methods without a save right afterward?

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364

1 Answers1

5

By looking at acts_as_state_machine's code (line 65) I found that it is defining event-methods without a bang too. This will update the state internally in the object without storing it to the database. Hope that helps :-)

Thorbjørn Hermansen
  • 3,522
  • 1
  • 21
  • 12
  • Note the [state_machine](https://github.com/pluginaweek/state_machine) gem non-bang methods still save the model (they just don't throw exceptions) – Adrian Macneil Aug 26 '13 at 22:46