Serializing deeply nested associations with active_model_serializers

前端 未结 6 1642
無奈伤痛
無奈伤痛 2020-12-08 06:37

I\'m using Rails 4.2.1 and active_model_serializers 0.10.0.rc2

I\'m new to API\'s and chose active_model_serializers because i

6条回答
  •  隐瞒了意图╮
    2020-12-08 07:15

    Per commit 1426: https://github.com/rails-api/active_model_serializers/pull/1426 - and related discussion, you can see that the default nesting for json and attributes serialization is one level.

    If you want deep nesting by default, you can set a configuration property in an active_model_serializer initializer:

    ActiveModelSerializers.config.default_includes = '**'

    For detailed reference from v0.10.6: https://github.com/rails-api/active_model_serializers/blob/v0.10.6/docs/general/adapters.md#include-option

提交回复
热议问题