state_machines-audit_trail icon indicating copy to clipboard operation
state_machines-audit_trail copied to clipboard

Memoization or something else on dynamic context

Open duleorlovic opened this issue 8 years ago • 3 comments

I had some legacy code that works find using old state_machine-audit_trail gem. After upgrading I noticed that when I create new objects, those initial transitions are not properly set. On old gem I see that only on @post.save hook, audit trail generate context messages. But now I see that context messages are generated on Post.new.

I can't pass all params to Post.new post_params since I need some calculations. Only initial params are used to create audit trail context messages.

Here is example app https://github.com/duleorlovic/state_machines-audit_trail You can notice that hard coded name is not used in audit trail even it is before .save.

I'm not sure if this is related to active record https://github.com/state-machines/state_machines-activerecord/issues/38 or to audit_trail... anyway we need to update migration document https://github.com/state-machines/state_machines-audit_trail/wiki/Converting-from-former-state_machine-audit_trail-to-state_machines-audit_trail

duleorlovic avatar May 18 '17 17:05 duleorlovic

If you think something may be broken, it would be best to submit a breaking test as a PR (either add an assertion or create another scenario). This test looks relevant: https://github.com/state-machines/state_machines-audit_trail/blob/master/spec/lib/state_machines/audit_trail/backend/active_record_spec.rb#L13

If there is an update to be made to the wiki, I think it is open so you can edit it.

rosskevin avatar May 18 '17 18:05 rosskevin

Thanks @rosskevin for instructions, I created failing test...

https://github.com/state-machines/state_machines-audit_trail/pull/23

duleorlovic avatar May 19 '17 07:05 duleorlovic

Any plans to get the fix merged into master? https://github.com/state-machines/state_machines-audit_trail/pull/29

andrewtubman avatar Jul 27 '20 19:07 andrewtubman