I'm using active model serializers(0.10.2) with :json adapter because in two serializers I need meta tag(meta tag is not included in :attributes adapter), I have few more serializers where I don't want root, is it possible to disable root per serializer?
Is it possible to use :json adapter in active model serializers v 0.10.2 and disable root?
I couldn't find a way to disable the root key when using the :json adapter. But, it sounds like you want to have some controller methods return meta data and other controller methods NOT return meta data, so you could use the default adapter (attributes) for methods with no meta data and then just declare the :json adapter on the controller methods where you need the meta data.
So, something like:
render json: articles, meta: articles_meta_method(articles), adapter: :json
of course articles_meta_method would have to be defined somewhere.
There's an example of using a meta method for pagination here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With