
ruby
iteye_15986
这个作者很懒,什么都没留下…
展开
-
数组里元素为字符串的排序方法 -- sort_by
s=["ruby is an interesting language"]a = s.split(/ /)a.sort_by{|i| i}原创 2012-08-03 15:00:23 · 280 阅读 · 0 评论 -
ruby 习题
#1.1#生成100个0到99之间的随机整数,找出它们之中的最大者和最小者,并统计大于50的整数个数 a = []sum = 00.upto(99) {|i|j = rand(i).to_i a 50 }max = a.maxmin = a.minp a puts max,min,sum#1.2#1到11有4个"1",1中一个"1"...原创 2012-08-03 15:06:32 · 484 阅读 · 2 评论 -
ruby 环境变量(根据各现场而改变)
ruby 环境变量的设定config/environment.rb$PON_IP = "192.168.1.31"(每个现场自己配IP地址)前台取 :host=> $PON_IP2012-08-07 11:04:26 · 274 阅读 · 0 评论 -
ruby on rails 知识点(上)
1.Controller中的公開(public)方法都是Action,也就是可以讓瀏覽器呼叫使用的動作。使用protected或private可以避免內部方法被當做Action使用。2.def create @event = Event.new(params[:event]) if @event.save redirect_to :action => :index...原创 2012-08-22 14:29:32 · 121 阅读 · 0 评论