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

Define a class method to introspect valid delegatable types so they can #50662

Merged

Conversation

jprosevear
Copy link
Contributor

@jprosevear jprosevear commented Jan 9, 2024

Motivation / Background

While dealing with strong parameters in API requests and validating the polymorphic type field for a delegated type in a slightly abstract manner, its useful to have access to the allowed types.

Detail

This Pull Request changes the methods defined by ActiveRecord::DelegatedType

Additional information

N/A

Checklist

Before submitting the PR make sure the following are checked:

  • 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.

be used to validate the type column and power strong parameters.
@rafaelfranca rafaelfranca merged commit 883b033 into rails:main Jan 15, 2024
4 checks passed
@@ -3007,6 +3007,7 @@ With this definition complete, our `Entry` delegator now provides the following

| Method | Return |
|---|---|
| `Entry#entryable_types` | ["Message", "Comment"] |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Entry.entryable_types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#50819 @tanaken0515 fixed this already - thanks!

@jprosevear jprosevear deleted the feature/delegated-type-types-introspection branch January 25, 2024 20:28
sampatbadhe added a commit to sampatbadhe/rails that referenced this pull request May 12, 2024
Correct typo in activerecord changelog for -rails#50662
fractaledmind pushed a commit to fractaledmind/rails that referenced this pull request May 13, 2024
Correct typo in activerecord changelog for -rails#50662
dhh pushed a commit that referenced this pull request May 14, 2024
Correct typo in activerecord changelog for -#50662
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.

None yet

3 participants