ruby on rails內建方法之物件是否為空blank?
puts [ ].blank? #=> true
puts .blank? #=> false
puts " cat ".blank? #=> false
puts "".blank? #=> true
puts " ".blank? #自動去除前後空格=> true
puts nil.blank? #=> true
ruby on rails內建方法之排序:group_by()
groups = posts.group_by
ruby on rails內建方法之組句:to_sentence()
puts [ "ant", "bat", "cat"].
to_sentence #=> "ant, bat, and cat"
puts [ "ant", "bat", "cat"].
to_sentence(:connector =>
"and not forgetting")
#=> "ant, bat, and not forgetting cat"
puts [ "ant", "bat", "cat"].
to_sentence(:skip_last_comma => true)
#=> "ant, bat and cat"
ruby on rails內建方法之分組:in_groups_of()
[1,2,3,4,5,6,7].in_groups_of(3)
#=> [1, 2, 3]
[4, 5, 6]
[7,nil, nil]
[1,2,3,4,5,6,7].in_groups
_of(3,"x")
#=> [1, 2, 3]
[4, 5, 6]
[7,"x", "x"]
ruby on rails內建方法之字串方法:
string = "now is the time"
puts string.at(2) #=> "w"
puts string.from(8) #=> "he time"
puts string.to(8) #=> "now is th"
puts string.first #=> "n"
puts string.first(3) #=> "now"
puts string.last #=> "e"
puts string.last(4) #=> "time"
puts string.starts_with?("no") #=> true
puts string.ends_with?("me") #=> false
count = hash.new(0)
string.each_char
p count #=>
Ruby On Rails 常見問題
環境 windows vista home premium 1 使用gem更新gem自己 gem update system 2 安裝rails gem install rails include dependencies 之後確認版本 3 使用mongrel伺服器 ruby預設沒有安裝 gem i...
幾種效能強大Ruby on Rails外掛程式介紹
2009 12 16 15 14 佚名 ddvip.com 字型大小 t t ruby on rails外掛程式可以更加優化我們的ruby on rails工具。比如 檔案上傳 主題支援 動態的樹型結構 國際化外掛程式等等。ad ruby on rails作為一款功能強大的web開發框架,能幫助我們...
初學Ruby On Rails有感
因為看到一些牛人的部落格裡都有了對ruby on rails的認可,感覺主流的思想開始向rails傾斜了,那麼自己也不得不趕緊跟上,想法弄到了一本 應用rails進行敏捷web開發 之所以選擇它是因為它有rails,有ruby語法的講解還有敏捷一詞.這麼多讓我感興趣的東西集合到一起,我認定這會是一本...