Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1800

as_json not working with Rails render for embedded docs

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.4.7
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

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

      I can confirm that MONGOID-1757 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:

      1. Produces the correct output for the embedded docs
        p out.as_json
      1. Once it's rendered, only the root respects the as_json override, the embedded docs are not respected.
        render json: out

            Assignee:
            Unassigned Unassigned
            Reporter:
            wprater wprater
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None