How to render json with extra data with active_model_serializer on rails?
<p>Using Rails 4.1.6 and active_model_serializers 0.10.3</p>

<p>app/serializers/product_serializer.rb</p>

<pre><code>class ProductSerializer &lt; ActiveModel::Serializer
  attributes :id, :title, :price, :published
  has_one :user
end
</code></pre>

<p>app/controllers/api/v1/products_controller.rb</p>

<pre><code>class Api::V1::ProductsController &lt; ApplicationController
  respond_to :json

  def index
    products = Product.search(params).page(params[:page]).per(params[:per_page])
    render json: products, meta: pagination(products, params[:per_page])
  end
end
</code></pre>

<p>When I check the response body, it shows the products data only:</p>

<pre><code>[{:id=&gt;1, :title=&gt;"Side Auto Viewer", :price=&gt;"1.6999510872877", :published=&gt;false, :user=&gt;{:id=&gt;2, :email=&gt;"indira.sawayn@watsica.us", :created_at=&gt;"2016-12-29T03:44:40.450Z", :updated_at=&gt;"2016-12-29T03
:44:40.450Z", :auth_token=&gt;"ht7CsFWM1hvSGKM_zPmU"}}, {:id=&gt;2, :title=&gt;"Direct Gel Mount", :price=&gt;"56.7935950121941", :published=&gt;false, :user=&gt;{:id=&gt;3, :email=&gt;"jaye.rolfson@leuschke.info", :created_at=&gt;
"2016-12-29T03:44:40.467Z", :updated_at=&gt;"2016-12-29T03:44:40.467Z", :auth_token=&gt;"MTK_5rkFv8E6Fy7gyAtM"}}, {:id=&gt;3, :title=&gt;"Electric Tag Kit", :price=&gt;"46.4689779902597", :published=&gt;false, :user=&gt;{:id=
&gt;4, :email=&gt;"tatiana@moen.co.uk", :created_at=&gt;"2016-12-29T03:44:40.479Z", :updated_at=&gt;"2016-12-29T03:44:40.479Z", :auth_token=&gt;"fTd8z7PCLHxZ7aewLPDY"}}, {:id=&gt;4, :title=&gt;"Remote Tuner", :price=&gt;"48.2478
906626996", :published=&gt;false, :user=&gt;{:id=&gt;5, :email=&gt;"pauline.gaylord@hettinger.info", :created_at=&gt;"2016-12-29T03:44:40.486Z", :updated_at=&gt;"2016-12-29T03:44:40.486Z", :auth_token=&gt;"XC7ZhcyfPrpEyDw-M15
1"}}]
</code></pre>

<p>The extra data <code>meta</code> was not been picked up. Is this <code>active_model_serializers</code> version not support that? Or is there a way can get extra data?</p>

<hr>

<h1>Edit</h1>

<p>The <code>pagination</code> method:</p>

<pre><code>def pagination(paginated_array, per_page)
  { pagination: { per_page: per_page.to_i,
                  total_pages: paginated_array.total_pages,
                  total_objects: paginated_array.total_count } }
end
</code></pre>