随笔分类 - ruby
摘要:环境 ubuntu 14.04为了安装rails4.2 和 ruby 2.2.2,这是目前稳定的最新版本,需要先安装rvmsudo apt-get updatesudo apt-get install curl\curl -L https://get.rvm.io | bash -s stable ...
阅读全文
摘要:utf-8必须置顶,如果放在其他位置,会导致后面如果遇到中文无法解析,然后报其他乱七八糟的错误,比如不能连接数据库,比如语法错误。。。。。。这种错误不好找,切记!!!出错代码:#!/bin/env ruby $: << '/var/lib/gems/1.9.1/gems/librrd-1.0.4/e...
阅读全文
摘要:f = "app/assets/#{vm.uuid}.rrd" if FileTest::exist?(f) File.delete(f) end
阅读全文
摘要:使用select来选择,,,选择就响应真是花了好大的功夫。。。。你妹。。。在controller设置变量来储存选择后的值。。。js中如果select选择为空那么传入的值是””而不是nullselectedIndex的值都是数字,从0开始,而不是option的值controller#sdn的网络流量监...
阅读全文
摘要:class MysqlTest #Code here require "mysql" def testMysql dbc=Mysql.real_connect('localhost','root','123','Ivic_Portal') res=dbc.query('select...
阅读全文
摘要:http://ruby-metaprogramming.rubylearning.com/html/ruby_metaprogramming_2.htmlhttp://galeki.is-programmer.com/posts/183.html1.3.2 sendsend( )is an inst...
阅读全文
摘要:隐藏html的标签 我的虚拟网络 > > > >
阅读全文
摘要:在render中,即使有:action,那么也仅仅是取对应的view中的模板(html.erb)而已,所以这里即使浏览器中的url是/orders/xcreate,但是显示的界面是/app/views/orders/xshow的代码 def xcreate flash.now[:notice...
阅读全文
摘要:link_to和其对应要跳转的的url,用path和直接路由方法看看link_to "alert(1)"} %> 在rake routes中看到,定义好的路由是:C:\Users\Administrator\Desktop\lianxizhong\lianxi1_form_f...
阅读全文
摘要:原创,转载请注明http://www.cnblogs.com/juandx/p/3963023.htmlrails中path、url路径解析,routes信息,form_for剖析,link_to示例1、首先要了解routes中resources的member、collection、new的关系 =...
阅读全文
摘要:D3js技术文档概述 D3 allows you to bind arbitrary data to a Document Object Model (DOM), and then apply data-driven transformations to the document. For exam...
阅读全文
摘要:d3js拓扑关系特效可视化展现在上一篇d3js文档http://www.cnblogs.com/juandx/p/3959900.html中讲了简单的d3js方法和效果,现在我做一个完整的演示,使用d3js来展现动态可视化的网络拓扑效果图,希望对大家有所帮助。 D3 Page Templa...
阅读全文
摘要:arr = [1,2,3]1) arr2 = arr.each{|element| element = element * 2} #arr与arr2仍然都等于[1,2,3] each返回原数组 遍历内对元素的更改不会保存2) arr2 = arr.map{|element| element = el...
阅读全文
摘要:#虚拟网络拓扑的json数据 def topodata #@vnic = Vnic.all #flash.now[:notice] = 'Message sent!' #flash.now[:alert] = 'Message sent!' simple_json = { nodes:...
阅读全文
摘要:tASSOC means the => operator
阅读全文
摘要:实现json、做出提示框1、在controller中使用flash.now[:alert] = "str"方法来做printdef topodata #@vnic = Vnic.all #flash.now[:notice] = 'Message sent!' #flash.now[:aler...
阅读全文
摘要:class SwitchesController [:index, :show] def index end def show end #存储拓扑 def topo @vts = VmToSwitch.all @sts = SwitchToSwitch.all @st...
阅读全文
摘要:file是以_开头命名的文件,比如_cart.html.erb这样就可以用render来调用了还可以传参数比如rails 2.0p87传一个集合render(:partial => "cart_item", :collection => @cart.items)这样局部模板就得到了一个变量如cart...
阅读全文
摘要:web敏捷开发 p317depot > ruby script/console>>rs = ActionController::Routing::routes可以简单测试比如>>puts rs.routes>>rs.recognize_path "/store">>rs.generate :cont...
阅读全文
摘要:ubuntu 12.04绑定rrdrubygem install librrd用来装rrdruby,这样才能找到RRD.so文件然后在rb文件中加入这两句话:$: << '/path/to/rrdtool/lib/ruby/1.8/i386-linux'require "RRD"debian一开始g...
阅读全文