Active-model-serializers different result for client or framework

50 views Asked by At

I have an old rails app with classic view rendered with rails and public API at /api/v1/. I would like to replace classic views with Ember, no problem with that but I have to give sometimes more infos to ember than I normally give threw the public api.

In a design concern, making a new api only for the ember seems a lot, does active-model-serializers have the ability to choose which attributes will be "render" ? Very often it's one or two fields that are missing.

Cheers

1

There are 1 answers

0
Yury Lebedev On BEST ANSWER

You can actually create more then one serializer for each record, and specify which one you need in the controller:

render json: @posts, each_serializer: Dashboard::PostSerializer