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
fix: destroy when using forms and display fields API #2415
fix: destroy when using forms and display fields API #2415
Conversation
Code Climate has analyzed commit 9590f39 and detected 0 issues on this pull request. View more on Code Climate. |
# Get view from params unless actions is index or show or forms... | ||
# Else, for example for detach action we want the view from params to can fetch the correct fields | ||
view = if action_view.in?([:index, :show, :new, :edit, :create]) | ||
action_view | ||
else | ||
params[:view] || action_view | ||
end |
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.
This logic avoid the following scenario:
When a has many field is rendered the action is index
and params[:view]
is show
or edit
but we want to keep @view
as index
for the related_resource
Same do not happen with other actions except the list on L126
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.
Please add this as a comment in the code so we know why it's there.
# Get view from params unless actions is index or show or forms... | ||
# Else, for example for detach action we want the view from params to can fetch the correct fields | ||
view = if action_view.in?([:index, :show, :new, :edit, :create]) | ||
action_view | ||
else | ||
params[:view] || action_view | ||
end |
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.
Please add this as a comment in the code so we know why it's there.
This PR has been merged into Please check the release guide for more information. |
Description
Fixes #2403
The detach button request has been updated to no longer hydrate the resource using the
destroy
view, as it was identified as a problematic approach when usingdef display_fields
ordef form_fields
API since those methods wouldn't get called.To address this, we have modified the process to include passing the current view as parameters during the detach request. This ensures that the appropriate view is properly hydrated into the resource.
Checklist:
I have made corresponding changes to the documentationScreenshots & recording
Before
before.webm
After
after.webm
Manual review steps
def display_fields
anddef form_fields
API