Multiple selection for inclusion-validated task attributes

Open
#1,565 0 comments 0 reactions 0 assignees View on GitHub

@efegokdemir is already working on this.

Since Oct 18, 2026.

  • #1570 by @efegokdemir — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rails, ruby
Domain
backend

Research direction

Start with TasksHelper#parameter_field in the engine's app/helpers, where inclusion-validated attributes become a single select, and the task attribute handling that casts run arguments. Decide between a shipped array attribute type and a per-task declaration, then add tests covering rendering and casting of the submitted array with its hidden blank value. Done means a multiple select stores and round-trips a list of values through the run form.

Written by the indexing model from the issue text.

Description

When a task attribute has an inclusion validator, the run form renders it as a single <select> (TasksHelper#parameter_field). There is no way to let the person running the task pick several values from the same list.

Our case is a task that takes a logical dump of a chosen set of database tables. The options come from a proc (inclusion: { in: ->(_) { ActiveRecord::Base.connection.tables.sort } }), and the task needs one or more of them. Without a multiple select, the choice is between a free-text, comma-separated field (no list to pick from, typos only caught by validation) and overriding the gem's helper.

Most of the pieces already work with arrays:

  • Rails' inclusion validator checks arrays element by element;
  • run arguments are stored as JSON, so an array round-trips.

What is missing:

  1. Rendering: parameter_field would need to pass multiple: true to select for such attributes.
  2. Casting: ActiveModel has no array attribute type, so the attribute needs a type that casts the submitted array and drops the hidden blank value Rails adds to multiple selects.

Our workaround on 2.17.0 is a small ActiveModel::Type::Value subclass for string lists, plus a module prepended to MaintenanceTasks::TasksHelper that renders attributes of that type as select(..., multiple: true). It works, but it depends on a private helper's signature.

Would you accept built-in support? Two shapes come to mind:

  • the gem ships an array attribute type (e.g. attribute :tables, MaintenanceTasks::Types::StringList.new), and parameter_field renders a multiple select when an inclusion-validated attribute uses it;
  • or a declaration on the task, e.g. multiple_select :tables.

Happy to open a PR with whichever approach you prefer, including tests.

Dominant language
Ruby
Stars
1.3k
Forks
115
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Shopify/maintenance_tasks

All issues in Shopify/maintenance_tasks

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.