I'm using rails-api
with serializers and I'm especially looking for an easy way to implement "sparse fieldset", that means I want my Rails API to render (json) only the fields I give in the parameter fields
:
http://api.website.com/v1/ressource/id?fields=field1,field2
I know we can get field1
, field2
etc with params[:field]
into the ressource controller, but I'm still not sure: the problem has to be fixed into the controller ? model ? serializer ?
I have seen few posts on this topic and no one is finally given a strong and universal response to this problem. How well-known Rails API are doing this ?
Thank you by advance for your explanations and advice.