Ruby變數名的首位字元來確定它是局部變數、執行個體變數、類變數、全域變數還是常數。通常情況下,變數名的第二位字元以後是數字、字母或底線,但有的內部變數名比較特殊s = 'Hello World!'x = 10# p004stringusage.rb# Defining a constantPI = 3.1416puts PI# Defining a local variablemyString = 'I love my city, Pune'puts
標籤:需求:給人搭配不同的服飾代碼版本一# -*- encoding: utf-8 -*-class Person attr_accessor :name def initialize(name) @name = name end def wear_t_shirts puts ‘大T恤‘ end def wear_big_trouser puts ‘垮褲‘ end def
標籤:ruby on rails上傳報錯Encoding::UndefinedConversionError in ProductsController#create"\xFF" from ASCII-8BIT to UTF-8在使用ruby1.9.3做上傳照片的時候,報這個錯誤,解決辦法是將控制器裡的File.open("#{Rails.root}/app/assets/images/"+new_name, "w") { |file|
Ruby 1.9.3-p0 makes psych—the replacement for 1.8.7’s YAML library, Syck—the default YAML parser. Psych is a wrapper around libyaml, so you’re going to need it installed and configured before installing Ruby.If you install 1.9.3-p0 without libyaml,
git倉庫輸出 git archive --format=tar --prefix=actasfavor/ HEAD | (cd /home/holin/work/ && tar xf -) 輸出到/home/holin/work/actasfavor/目錄下 Posted by holin At May 16, 2008 16:42 載入plugins中的controller和model # Include hook code here require