I am using a RABL gem to display user JSON data for comment users, which are child annotations that are child elements of images. I would like to do something similar to:
object @image
node :annotations do
@image.annotations.map { |a| {
:id => a.id,
:x1 => a.x1,
:x2 => a.x2,
:y1 => a.y1,
:y2 => a.y2,
node :comments do
@image.annotations.comments.map { |c| {
:body => c.body,
:user_id => c.user_id,
:name => User.find(c.user_id).name,
:user_icon => user_icon(User.find(c.user_id), 'square', 30)
}}
end
}}
end
I know this is not true in RABL, I also tried using a child instead of node, but I was not able to access the user data in this way. How do I do this and what is the correct syntax for this to happen?
source
share