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

Allow more flexibility in how serializers are resolved when strings are passed to the serializer option #119

Merged
merged 1 commit into from
Jun 4, 2022

Conversation

ryoung
Copy link
Contributor

@ryoung ryoung commented Jun 3, 2022

This PR allows has_one and has_many associations to use a different serializer than the association name, if a string is passed in for the serializer.

Using a real world example - If you have this defined: has_one :current_driver, serializer: "User" in a Vehicle, the serializer resolver will always look for CurrentDriverSerializer, which is not the correct serializer, because we wanted a UserSerializer.

Not all serializers are named the same as the association. If a serializer string is passed to the has_one
or has_many association, we can look up the serializer name directly, instead of appending Serializer to the
association name.
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.

None yet

2 participants