title: ActiveModel::Serializers JSON API nested associations needs to include a value
body: <p>I have an Rails 7 API and i'm using <code>gem 'active_model_serializers', '~&gt; 0.10.0'</code> to make het fit in the json_api requirements, but i need to in the nested attributes of my items include the name, not only the id and type, i tried many things i found in the internet, but none of them solved this for my, and i'm hoping someone here could.</p>
  <p>my products_controller.rb</p>
  <pre><code>class ProductsController &lt; ApplicationController
  
    include ActionController::HttpAuthentication::Token::ControllerMethods
    before_action :authenticate
  
    include ErrorSerializer
  
    before_action :set_product, only: %i[ show update destroy ]
  
    # GET /products
    def index
      page_number = params[:page].try(:[], :number)
      per_page = params[:page].try(:[], :size)
  
  
      @products = Product.all.page(page_number).per(per_page)
  
      # paginate json: @products
      render json: @products, show_category: (param? params[:category]), show_unit: (param? params[:unit])
    end
  
    def all
      @products = Product.all
  
      render json: @products
    end
  
    # GET /products/1
    def show
      render json: @product
    end
  
  #The rest of crud options
  
    private
      # Use callbacks to share common setup or constraints between actions.
      def set_product
        @product = Product.find(params[:id])
      end
  
      # Only allow a list of trusted parameters through.
      def product_params
        params.require(:product).permit(:name, :description, :quantity_in_stock, :price, :highlight, :category_id, :unit_id)
      end
  
      def authenticate
        authenticate_or_request_with_http_token do |token, options|
          hmac_secret = ENV['TOKEN']
          JWT.decode token, hmac_secret, true, { :algorithm =&gt; 'HS256' }
        end
      end
  end
  </code></pre>
  <p>my product_serializer</p>
  <pre><code>class ProductSerializer &lt; ActiveModel::Serializer
    attributes :id, :name, :description, :quantity_in_stock, :price, :highlight
    
    belongs_to :category, optional: true
    belongs_to :unit, optional: true
  
    def should_render_category
      @instance_options[:show_category]
    end
    def should_render_unit
      @instance_options[:show_unit]
    end
  end
  </code></pre>
  <p>my unit_serializer:</p>
  <pre><code>class UnitSerializer &lt; ActiveModel::Serializer
    attributes :id, :name
  
    has_many :products, optional: true
  end
  </code></pre>
  <p>my category_serializer:</p>
  <pre><code>class CategorySerializer &lt; ActiveModel::Serializer
    attributes :id, :name
  
    has_many :products, optional: true
  end
  </code></pre>
  <p>and my application_controller:</p>
  <pre><code>class ApplicationController &lt; ActionController::API
    before_action :ensure_json_request
  
    def param? param
  
      param &amp;&amp; param != &quot;false&quot; &amp;&amp; param != &quot;nil&quot;
    
    end
  
    def ensure_json_request
      unless request.headers[&quot;Accept&quot;] =~ /vnd\.api\+json/
        render body: nil, :status =&gt; 406
      else
        unless request.get?
          return if request.headers[&quot;Content-Type&quot;] =~ /vnd\.api\+json/
          render body: nil, :status =&gt; 415
        end
      end
    end
  end
  </code></pre>
  <p>And my actual response:</p>
  <pre><code>{
              &quot;id&quot;: &quot;1&quot;,
              &quot;type&quot;: &quot;products&quot;,
              &quot;attributes&quot;: {
                  &quot;name&quot;: &quot;Lightweight Iron Keyboard&quot;,
                  &quot;description&quot;: &quot;Sit quas ipsa. Animi non omnis. Eveniet et quidem.&quot;,
                  &quot;quantity-in-stock&quot;: 99,
                  &quot;price&quot;: 27.88,
                  &quot;highlight&quot;: false
              },
              &quot;relationships&quot;: {
                  &quot;category&quot;: {
                      &quot;data&quot;: {
                          &quot;id&quot;: &quot;4&quot;,
                          &quot;type&quot;: &quot;categories&quot;
                      }
                  },
                  &quot;unit&quot;: {
                      &quot;data&quot;: {
                          &quot;id&quot;: &quot;2&quot;,
                          &quot;type&quot;: &quot;units&quot;
                      }
                  }
              }
          }
  </code></pre>