{
  "user": {
    "id": 1,
    "name": "John Smith",
    "posts": [
      {
        "id": 1,
        "title": "Hitchin' Ride"
    ]
  }
}
というJSONを作りたいとき、"posts"が配列だからcollectionでも使えばいいのかなと思ったけど、どうにもうまくいかなかった。結局nodeを使うのが楽だった。
object nil child @user do attributes :id, :name node(:posts) { @user.posts.map { |post| { id: post.id, title: post.title }} } end
もっといい方法があるのかもしれない。