I'm having an issue with limiting the level of associations serialized within an active model resource.
For example:
A Game has many Teams which has many Players
class GameSerializer < ActiveModel::Serializer
attributes :id
has_many :teams
end
class TeamSerializer < ActiveModel::Serializer
attributes :id
has_many :players
end
class PlayerSerializer < ActiveModel::Serializer
attributes :id, :name
end
When I retrieve the JSON for the Team, it includes all the players in a sub array, as desired.
When I retrieve the JSON for the Game, it includes all the Teams in a sub array, excellent, but also all the players for each Team. This is the expected behaviour but is it possible to limit the level of associations? Have Game only return the serialized Teams without the Players?