I'm trying to building some json output from rails using jbuilder. i have something like:
json.links do | i |
i.array!( @links ) do | j, link |
j.source link['source']
j.target link['target']
j.stats do | s |
[ 'item1', 'item2' ].each { |item|
s.item statistics_path( :source => link['source'], :metric => item )
}
end
end
end
of course, this results in something like:
{
links: [
source: "a",
target: "b",
stats: {
item: 'url for item2'
}
]
}
when i actually want something like:
{
links: [
source: "a",
target: "b",
stats: {
item1: 'url for item1',
item2: 'url for item2'
}
]
}
any ideas?