mongoid/mongoid — Issue #1799: as_json not working with Rails render for embedded docs
Author: wprater
Created: 2012-03-07 19:25:22+00:00
State: open

Hoping that issue https://github.com/mongoid/mongoid/issues/1756 would fix my issue, but this is not the case.

I can confirm that #1756 does fix the as_json calls for embedded docs, but once they get passed to #render, embedded docs do not seem to produce their as_json in the output. The root doc will produce the as_json override, but the embedded docs do not when using rails #render on rails 3.1.4 (also tried latest 3.2.x branch).

This was not the behavior on mongoid 2.3.x.

for example:

# Produces the correct output for the embedded docs
p out.as_json

# Once it's rendered, only the root respects the as_json override, the embedded docs are not respected.
render json: out