草庐IT

CollectionSerializer

全部标签

ruby - ActiveModel::Serializer::CollectionSerializer

我正在使用ActiveModelSerializersv0.10.0.rc4我想生成如下所示的json:{"posts":[{"post":{"id":2,"name":"foo"}},{"post":{"id":3,"name":"bar"}}],"next_page":3}我知道基本的:renderjson:posts,each_serializer:PostSerializer将生成这样的json:[{"id":2,"name":"foo"}{"id":3,"name":"bar"}]我尝试了以下操作:Controller:renderjson:posts,serializer: