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

时间:2014-09-04 01:32:07   收藏:0   阅读:157

#虚拟网络拓扑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

原文:http://www.cnblogs.com/juandx/p/3955103.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!