Skip to content

Instantly share code, notes, and snippets.

@aeldaly
Created July 9, 2015 13:49
Show Gist options
  • Select an option

  • Save aeldaly/b1c2e4d1d14ea2029e26 to your computer and use it in GitHub Desktop.

Select an option

Save aeldaly/b1c2e4d1d14ea2029e26 to your computer and use it in GitHub Desktop.
def index
# version 3 or greated supports embedding post comments
if derived_version >= 3
render json: @posts.includes(:comments), serializer: V3::PostSerializer
else
# shared code for all versions
render json: Post.scoped # defaults to PostSerializer
# could also do
# render json: Post.scoped, serializer: V2::PostSerializer
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment