I am using rails 5 and i am using jbuilder for sending json. The problem i am facing is i want to merge 2 table json and send it to same key..
my json.jbuilder look like this
json.children env.sites do |site|
json.nodeId "site_#{site.id}"
json.type "site"
json.extract! site,:id, :key, :name
json.children site.networks do |network|
json.nodeId "network_#{network.id}"
json.type "network"
json.extract! network,:id, :name
json.children network.vlans do |vlan|
json.type "vlan"
json.extract! vlan,:id, :name
end
end
json.children site.instances do |instance|
json.type "host"
json.extract! instance,:id, :name
json.content do
json.cpu instance.cpu
end
end
end
Issue i am facing over here is i want to merge site.networks and site.instaces in same key.. How i would achieve this..??