active_model_serializersで同じモデルから出力結果の違う2つのコントローラーを設定する

article_serializers.rb
class ArticleSerializer < ActiveModel::Serializer
  attributes :id, :title, :description
  has_one :region
  has_many :info_blocks

  # article has one region, region has one countryの関連を返す。
  class RegionSerializer < ActiveModel::Serializer
    attributes :id, :name
    has_one :country

    class CountrySerializer < ActiveModel::Serializer
      attributes :id, :name, :currency
    end
  end

  # article has many info_blocks,
  # info_block has many spendings, transportationsの関連を返す。
  class InfoBlockSerializer < ActiveModel::Serializer
    attributes :id, :event, :place, :comment
    has_many :spendings
    has_many :transportations

    class SpendingSerializer < ActiveModel::Serializer
      attributes :id, :genre, :cost
    end

    class TransportationSerializer < ActiveModel::Serializer
      attributes :id, :means, :cost
    end
  end
end


articles_controller.rb
class ArticlesController < ApplicationController
  def index
    @articles = Article.all
    render json: @articles, include: { region: [:country] }
  end

  def show
    @article = Article.find(params[:id])
    render json: @article, include: {info_blocks: %i[spendings transportations]}
  end
end


参考記事:
ActiveModelSerializerでネストしたアソシエーションを出力する方法 - Qiita