R – Using acts_as_state_machine transition methods without saving

acts-as-state-machinerubyruby-on-rails

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?

Best Answer

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 :-)