Skip to content

Instantly share code, notes, and snippets.

@UsamaAshraf
Created May 23, 2021 16:54
Show Gist options
  • Save UsamaAshraf/bc9303a07a14dfd621b46fc6385a6403 to your computer and use it in GitHub Desktop.
Save UsamaAshraf/bc9303a07a14dfd621b46fc6385a6403 to your computer and use it in GitHub Desktop.
posts = Post.all
author_ids = posts.pluck(:author_id)
authors = User.where(:_id.in => author_ids)
# Somehow pass the author objects to the post serializer and
# map them to the correct post objects. Can't imagine what
# exactly that would look like, but probably not pretty.
render json: posts, pass_some_parameter_maybe: authors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment