Unable to specify :include option in to_json for collection of model

XMLWordPrintableJSON

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

      I was trying to specify the :include option to the to_json Document methods in order to include model associations in the generated json, but it turns out that it is not possible to do that on a collection, only when dealing with a single model instance.
      Example:
      MyModel.all.entries.to_json :include => :myrelationship

      This ends up not including "myrelationship" in the generated json code at all. However, this works in this case:
      MyModel.first.to_json :include => :myrelationship

      Tested with mongoid 2.0.0 rc6

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

              Created:
              Updated:
              Resolved: