Hi, I just noticed that Discourse uses older version of ActiveModelSerializer.
It was released five years ago and I don’t think it’s good.
It seems that it’s planned to fork AMS but there’s a better solution.
My suggestion here to migrate from AMS to Alba, a JSON serializer I created and maintain. Although Alba is not 100% compatible with AMS, the API it offers is similar to AMS and about 10 times faster than latest AMS.
If the maintainers agree on migration, I’ll send a PR.
I believe it makes performance improvements so I’ll run benchmark script.
I didn’t know about serializer plugins. I found one example of plugins that customize serializer.
Here, include_votes? method seems a magic method from AMS since I cannot find where it’s used in the codebase. I think we need some migration in such cases since Alba doesn’t support this behavior.
Keeping compatibility must be important, so if I cannot make Alba compatible with existing plugins, I prefer not moving on.
Ah, thanks, it looks like it just defines some helper methods that returns whether the plugin is enabled or not and the plugin body. I think I can make it compatible with Alba, let me try.
Sorry. I didn’t look closely enough at the original plugin. I think that my hint might not be as helpful as I thought.
If what you’re doing is adding something to existing serializers (like adding a field to the post serializer), then I’ve helped. If you need to add a new route that returns its own information, then you’ll need to do something else.