Rails 3.1 deep nesting with RABL Rails 3.1 deep nesting with RABL json json

Rails 3.1 deep nesting with RABL


I got this answer from @calvin-l. The trick was to just map the a.comments then grab the data from each comment that way:

node :annotations do  @image.annotations.map { |a| {    :id => a.id,    :x1 => a.x1,    :x2 => a.x2,    :y1 => a.y1,    :y2 => a.y2,    :comments => a.comments.map { |c| {      :body => c.body,      :created_at => c.created_at,      :user => {        :id => c.user.id,        :facebook_id => c.user.facebook_id,        :name => c.user.name,        :username => c.user.username      }    }}  }}end