Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memoization or something else on dynamic context #22

Open
duleorlovic opened this issue May 18, 2017 · 3 comments
Open

Memoization or something else on dynamic context #22

duleorlovic opened this issue May 18, 2017 · 3 comments

Comments

@duleorlovic
Copy link

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 state-machines/state_machines-activerecord#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

@rosskevin
Copy link
Member

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.

duleorlovic added a commit to duleorlovic/state_machines-audit_trail-1 that referenced this issue May 19, 2017
It seems that context is evaluated on `.new` instead of `.save`
@duleorlovic
Copy link
Author

duleorlovic commented May 19, 2017

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

#23

gagalago added a commit to gagalago/state_machines-audit_trail that referenced this issue Jul 10, 2018
change after_initialize to before_create fix state-machines#22
gagalago added a commit to gagalago/state_machines-audit_trail that referenced this issue Jul 10, 2018
@andrewtubman
Copy link

Any plans to get the fix merged into master?
#29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants