Hacker News new | ask | show | jobs
by nightpool 1483 days ago
This library looks great for those using it, but I wish the situation for "ActiveRecord model -> JSON representation" in open-source libraries was better. This library seems to be overkill for that, since you'll almost always want completely separate code for "deserializing" attribute updates from a request, and it requires you to specify the type of every single property. ActiveModel::Serializer was great while it lasted, but it's unmaintained and missing a lot of features. Blueprinter seems a lot less battle-tested and may have performance problems. Last I looked, almost no library easily supports eager-loading. Is this right? I feel like I must be missing something. How do people render their models in modern Rails apps?
2 comments

Have you checked out Alba [0]? I think it’s one of the better options right now.

[0]: https://github.com/okuramasafumi/alba

I used a middle layer to transform ActiveRecord into, before put it in Serializer.