wvanbergen/state_machine-audit_trail — pull request #17 by hornairs (2013-09-16 20:40:14+00:00)
Title: Update the ActiveRecord backend to not save entries for records that aren't yet saved

If a state machine has `:action => nil` on it (like in Shopify), the saving of the record and the changing of its state are decoupled. This means that the state can be changed and state machine callbacks can be called on a new record without an ID yet, and its up to client code to save the record later.

That means its unsafe to try to create associated records until the record is saved. My code which calls `some_transition_trail_association.create` is doing this, so this PR changes it to do something smarter.

The state machine callbacks also get called when the record is saved even with action => nil, so I think this means we can just not create records if the record is new.

@wvanbergen you think thats ok?