Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hadrienblanc/5c6001c4a1867110127d867d385ed965 to your computer and use it in GitHub Desktop.
Save hadrienblanc/5c6001c4a1867110127d867d385ed965 to your computer and use it in GitHub Desktop.

Ancestry and Active record serializer

To have every child node included and serialized :

@business_stuff = BusinessStuff.commercial_subtree.arrange_serializable do |parent, children|
  BusinessStuffSerializer.new(parent, children: children)
end

render json: @business_stuff, include: '**'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment