I always forget all the different ways of serializing associations things, so putting down notes:
class AuthorSerializer < ActiveModel::Serializer
has_many :posts
emdThis will embed a array of post records into the author record.
{
"authors": {
"posts": []
}
}class AuthorSerializer < ActiveModel::Serializer
has_many :posts, embed: :ids
emdThis will embed post_ids and sideload the posts:
{
"posts": [],
"authors": {
"post_ids": []
}
}class AuthorSerializer < ActiveModel::Serializer
attributes :post_ids
emdThis will only embed the post_ids.
{
"authors": {
"post_ids": []
}
}