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

Support Rack 3 by renaming the name attributes of inputs #901

Merged
merged 2 commits into from
Oct 11, 2023
Merged

Conversation

etiennebarrie
Copy link
Member

@etiennebarrie etiennebarrie commented Oct 9, 2023

On the task pages, we would create runs for a task with attributes by having inputs named "[task_arguments][some_attribute]".

This is because we use fields_for in a FormBuilder initialized with a url, i.e. form_with(url:), which doesn't have an object_name, so when nested fields are generated, there's no object name before the first [.

Rack 3 changes the way form data is parsed, which causes all parameters to be available in params["[task_arguments]"] instead of params[:task_arguments].

Instead of handling this, we use fields_for directly on the view, not on the FormBuilder object, and we use the opportunity to rename task_arguments to task.

Now the inputs in the task page for a run will be named task[some_attribute] instead of [task_arguments][some_attribute].


I noticed in the PR upgrading Rails that the Postgres build was failing (#900). The reason is that it uses Rack 3 (since Rails 7.1 allows it), and once I ignored the Rack warnings (which will be solved in Capybara soon), I got the other failure related to the way Rack 3 parses form data.

This means that we're incompatible with Rails 7.1 and Rack 3, so I'll release a new patch version with this once merged.

On the task pages, we would create runs for a task with attributes by
having inputs named `"[task_arguments][some_attribute]"`.

This is because we use `fields_for` in a `FormBuilder` initialized with
a url, i.e. `form_with(url:)`, which doesn't have an `object_name`, so
when nested fields are generated, there's no object name before the
first `[`.

Rack 3 changes the way form data is parsed, which causes all parameters
to be available in `params["[task_arguments]"]` instead of
`params[:task_arguments]`.

Instead of handling this, we use `fields_for` directly on the view, not
on the `FormBuilder` object, and we use the opportunity to rename
`task_arguments` to `task`.

Now the inputs in the task page for a run will be named
`task[some_attribute]` instead of `[task_arguments][some_attribute]`.
This should be fixed in the next version of Capybara.
@etiennebarrie etiennebarrie merged commit 0d2e44d into main Oct 11, 2023
34 checks passed
@etiennebarrie etiennebarrie deleted the rack-3 branch October 11, 2023 19:41
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems October 11, 2023 20:15 Inactive
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 this pull request may close these issues.

2 participants