state-machines / state_machines-audit_trail

Log transitions on a state_machines gem to support auditing and business process analytics.
https://github.com/state-machines/state_machines-audit_trail
MIT License
75 stars 24 forks source link

namespaced events and states can be confused #1

Closed rosskevin closed 9 years ago

rosskevin commented 9 years ago

This is particularly confusing with multiple state_machines. An event called by #canceled_payment in the payment namespace should not be possibly confused with canceled in another, though both would be logged as such in the database.

It appears that #state_name (with no namespace) and #payment_state_name (in a payment namespaced state_machine) both yield canceled instead of a full state name like you would expect from the generated event method name.

rosskevin commented 9 years ago

The best options appears to be to add the namespace field to the state transition.

seuros commented 9 years ago

:+1:

seuros commented 9 years ago

what about machine or machine_name ?

rosskevin commented 9 years ago

Well, since the attribute on machine is namespace, I figured it might be best to label it as such.

 state_machine :alarm_state, initial: :active, namespace: :'alarm' do

So our field/value is namespace: 'alarm'

seuros commented 9 years ago

:shipit:

rosskevin commented 9 years ago

resolved with commit 61548c0bfb4ed49291f06d412b264b8a8c188708 and released as 1.0.1