active_model_serializers: 0.10.0.pre does not include meta in response

I was able to include meta info when I set ActiveModel::Serializer.config.adapter = :json_api. However, when I remove this option, there is no meta in the response. meta is included in the response once I switch to 0.8.3 version.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Meta If you want a meta attribute in your response, specify it in the render call:

render json: @post, meta: { total: 10 } The key can be customized using meta_key option.

render json: @post, meta: { total: 10 }, meta_key: "custom_meta" meta will only be included in your response if there’s a root. For instance, it won’t be included in array responses.

Why in 0.10 is not posible to include meta in Array responses? I think it has a great potencial, for example: pagination attributes.

{
  "data": [ ],
  "meta": {
    "pagination": {
      "total_count": 475,
      "total_pages": 10,
      "total": 50,
      "current_page": 1,
      "per_page": 50
    }
  }

Is this a bug or there is a good reason behind this? I’ll be glad to help if you need something.