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

[0.9 stable] Revert "Allow serializer_for to accept String instead of just class objects" #2468

Merged

Conversation

casperisfine
Copy link

Ref: 460d4c5

I first thought about making it configurable, but I just can't find a justification for this feature in a very stable gem with such backward compatibility impact.

cc @bf4

@Physium could you tell me more about your use case? Because this change broke our app quite hard, in a cause we had:

render json: "Error"

Which caused AMS to look for ErrorSerializer, which really we don't want.

Can't you just do:

render json: Custom.new

instead of:

render json: "Custom"

?

…bjects"

Ref: rails-api@460d4c5

I first thought about making it configurable, but I just can't find a
justification for this feature in a very stable gem with such backward
compatibility impact.
@casperisfine casperisfine force-pushed the 0-9-stable-revert-string-serializer branch from 0325a86 to aac72cf Compare April 10, 2024 08:23
@@ -49,7 +49,7 @@ def test_serializer_for_array_returns_appropriate_type
def object.serializer_class; CustomSerializer; end

assert_equal CustomSerializer, Serializer.serializer_for(object)
assert_equal CustomSerializer, Serializer.serializer_for('Custom')
assert_nil Serializer.serializer_for('Custom')
Copy link
Member

@bf4 bf4 Apr 11, 2024

Choose a reason for hiding this comment

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

I agree with reverting this behavior change

I either missed or misunderstood it when originally reviewing 460d4c5 in https://github.com/rails-api/active_model_serializers/pull/2446/files

Copy link
Member

@bf4 bf4 left a comment

Choose a reason for hiding this comment

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

Looks good. Behavior is surprising and shouldn't be supported

@Physium
Copy link
Collaborator

Physium commented Apr 11, 2024

@byroot apologies for the inconvenience. I dont recall the exact issue as to why I did this but its due to a ton of legacy code while I was trying to bring an 8 year old application back to life. I'm good with reverting this and will open another issue/pr again if your recommendation doesnt work out well.

@bf4 apologies, i think i took that pr to address issues within my application a little too extreme! looking back at it again it should have been a different PR.

Should we merge this?

@byroot byroot merged commit b5c18df into rails-api:0-9-stable Apr 11, 2024
7 checks passed
@casperisfine casperisfine deleted the 0-9-stable-revert-string-serializer branch April 11, 2024 06:30
@casperisfine
Copy link
Author

apologies for the inconvenience.

No worries.

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.

4 participants