Allow redefining to_param
delimiter using param_delimiter
#49020
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit allows customizing the delimiter used by
to_param
whento_key
returns multiple value. This unblocks supporting more varieties of composite primary key types in Active Record.This PR has a two commits:
param_delimiter
attribute to configure the delimiter in Active Modelto_param
to support composite primary key and utilizes newly addedparam_delimiter
along with defining AR default delimiter to_
It is possible to add composite primary key support to
to_param
without the delimiter abstraction by hardcoding certain value but it's really hard to choose one since we can't account for all possible values of the composite primary key values to avoid conflicts. And asking applications to override wholeto_param
seems inconvenientI would be more than glad to split these changes into two separate PR and avoid squashing as I would definitely like to keep these commits separated