title: JSON rendering with activemodel serializer in Rails
body: <p>I just wonder how the rails render the model objects with activemodel-serializer in JSON.
  I installed activemodel-serializer but the output is something different.</p>
  
  <p>The ideal is something like:</p>
  
  <pre><code>"products": [
    {
      "id": 1,
      "title": "Digital Portable System",
  
    },
    {
      "id": 2,
      "title": "Plasma TV",
    }
  
  ]
  </code></pre>
  
  <p>However what I got so far is;
  <a href="https://i.stack.imgur.com/SvYWL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SvYWL.png" alt="enter image description here"></a></p>
  
  <p>My code is simple;</p>
  
  <pre><code>class Api::V1::ProductsController &lt; ApplicationController
    before_action :authenticate_with_token!, only: [:create, :update, :destroy]
    respond_to :json
  
    def index
      respond_with Product.all  
    end
  
    def show
      respond_with Product.find(params[:id])   
    end
  
    def create
      product = current_user.products.build(product_params) 
      if product.save
        render json: product, status: 201, location: [:api, product] 
      else
        render json: { errors: product.errors }, status: 422
      end
    end
  
    def update
      product = current_user.products.find(params[:id])
      if product.update(product_params)
        render json: product, status: 200, location: [:api, product] 
      else
        render json: { errors: product.errors }, status: 422
      end
    end
  
    def destroy
      product = current_user.products.find(params[:id]) 
      product.destroy
      head 204
    end
  
    private
  
      def product_params
        params.require(:product).permit(:title, :price, :published) 
      end
  
  end
  </code></pre>