Skip to content

allow dom_id method to accept an array of records_or_classes - #50608

Closed
jwilsjustin wants to merge 1 commit into
rails:mainfrom
jwilsjustin:multi-model-dom-id
Closed

allow dom_id method to accept an array of records_or_classes#50608
jwilsjustin wants to merge 1 commit into
rails:mainfrom
jwilsjustin:multi-model-dom-id

Conversation

@jwilsjustin

Copy link
Copy Markdown

Context

See also: hotwired/turbo-rails#476

hotwired/turbo-rails/pull/476 removed the ability to pass multiple ids/models to the turbo_frame_tag helper method. In that PR it was suggested by @skipkayhil that this ability be passed down to the dom_id method (which is a part of rails core) method rather than the turbo_frame_tag helper (which is a part of turbo-rails).

ref: https://discuss.rubyonrails.org/t/allow-dom-id-method-to-accept-multiple-ids-models/84408

Changes

If the first argument of the dom_id is an array, this change will loop through each value and form a singular dom ID, then join the parts together. This change will allow turbo frame tags to accept multiple models (similar to the cache helper from ActionView).

<%= turbo_frame_tag [customer, field] do %>
  <!-- code -->
<% end %>

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@p8

p8 commented Jan 7, 2024

Copy link
Copy Markdown
Member

Related: #44081

ref: https://discuss.rubyonrails.org/t/allow-dom-id-method-to-accept-multiple-ids-models/84408

If the first argument (records_or_classes) is an array, this change will loop
through each value and form a singular dom id, then join the parts together.

This change will allow turbo frame tags to accept multiple models (similar to
the `cache` helper from ActionView).

```
<%= turbo_frame_tag [customer, field] do %>
  <!-- code -->
<% end %>
```

See also: hotwired/turbo-rails#476
@rafaelfranca

Copy link
Copy Markdown
Member

Closed by #55204

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants