When I have a has_many/belongs_to relationship in Rails 5 API with active_model_serializers
I can pass the option to include a nested model.
def show
render json: @post, include: ['comments']
end
It's also possible to get multiple layers of nesting.
def show
render json: @post, include: ['comments', 'comments.comment_likes']
end
I can't find documentation anywhere about adding conditions to the include statement. Is it possible to do something like this?
def show
render json: @post, include: ['comments'] { top_contributor: true }
end