-
Notifications
You must be signed in to change notification settings - Fork 141
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
create the resource action after save for custom buttons #821
create the resource action after save for custom buttons #821
Conversation
Rails 5.2 raises this error if you try to persist the child before creating the parent: `Failed to create new custom button - You cannot call create unless the parent is saved` Followup to ManageIQ#814 Needed for Rails 5.2: ManageIQ/manageiq#20032 thanks keenan and lj
cb5a8d3
to
5c730a4
Compare
Checked commit d-m-u@5c730a4 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint |
custom_button.save! | ||
custom_button.create_resource_action!(data["resource_action"].deep_symbolize_keys) if data.key?("resource_action") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious, can the create_resource_action! method somehow fail, and we end up with a created Object, but never used/returned ? do we need a transaction for the above two so the request is atomic ? @jrafanie thoughts ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really think so. resource action create 1) has no validations and 2) are artifacts that link dialogs, resources, and automate, there's not much of a vector for failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, probably similar to this one: ManageIQ/manageiq#20013
@d-m-u can you review if this is required and do a followup PR? This is great to fix the issue on rails 5.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cross our streams at the same time and didn't use a mutex
create the resource action after save for custom buttons (cherry picked from commit da3529c)
Jansa backport details:
|
otherwise this fails with
Failed to create new custom button - You cannot call create unless the parent is saved
on rails 5.2 🤮Keenan caught it in https://travis-ci.com/github/ManageIQ/manageiq-cross_repo-tests/jobs/325865143#L2435
@miq-bot add_label jansa/yes, ivanchuk/yes
@miq-bot add_reviewer @jrafanie
@miq-bot add_label bug
Followup to #814
Needed for Rails 5.2: ManageIQ/manageiq#20032