Active_model_serializers: I found that root: false option is not working.

Created on 8 Oct 2015  路  2Comments  路  Source: rails-api/active_model_serializers

I use ActiveModel::Serializer.config.adapter = :json as adapter, but the root: false option is not working.

render json: alliances,
           each_serializer: AllianceSerializer::Common,
           root: false

it will generate json as follow.

{ alliance:  { id: 123 } }

Most helpful comment

In master, the way to remove the root of the JSON document is by using the Attributes adapter. Just pass the adapter: :attributes to your render call.

All 2 comments

In master, the way to remove the root of the JSON document is by using the Attributes adapter. Just pass the adapter: :attributes to your render call.

ok, thx

Was this page helpful?
0 / 5 - 0 ratings

Related issues

attenzione picture attenzione  路  4Comments

greggawatt picture greggawatt  路  4Comments

kapso picture kapso  路  4Comments

steverob picture steverob  路  4Comments

Tybot204 picture Tybot204  路  3Comments