首页 > 代码库 > json flash.now[:notice] flash.now[:alert]

json flash.now[:notice] flash.now[:alert]

#虚拟网络拓扑json数据
def topodata
#@vnic = Vnic.all
#flash.now[:notice] = ‘Message sent!‘
#flash.now[:alert] = ‘Message sent!‘
@vnic = {
nodes: [{ name: ‘bob‘, age: "22", awesome: "true" }, { name: ‘bob‘, age: 22, awesome:true }],
links: [{ name: ‘bob‘, age: "22", awesome: "true" }, { name: ‘bob‘, age: 22, awesome:true }]
}
flash.now[:alert] = @vnic
respond_to do |format|
format.html
format.json { render json: @vnic } #这里会自动调用to_json
end
end

json flash.now[:notice] flash.now[:alert]