Suppose I have an Article
with n Comments
. How would I go about grabbing all the comments with the article in one query with DataMapper?
Something like the following false code:
Article.get(:id).include(:comments).to_json
I want the associated comments to be returned in the json like so:
{
article object
comments: [
{ comment object },
{ comment object }
]
}
Seems like there must be a better way than grabbing the comments, and manually adding them to an attributes hash before calling to_json.