標籤: 查詢了大神的經驗貼http://stackoverflow.com/questions/19078044/disable-activerecord-for-rails-4http://stackoverflow.com/questions/821251/how-to-configure-ruby-on-rails-with-no-database其中點贊最多的也是我用的方法If you are creating a new application, you can use
標籤:在一個ruby字串中包含表但是或者變數。想使用不同的值替換運算式或者變數 1 類似java 或者python的printf-style方式template = ‘Oceania has always been at war with %s.‘template % ‘Eurasia‘ # => "Oceania has always been at war with Eurasia."template % ‘Eastasia‘ # => "Oceania
標籤:# definefrench_string = "il \xc3\xa9tait une fois"long_string = <<EOFHere is a long stringWith many paragraphsEOFputs long_string.empty?puts long_string.include? "many"puts french_string + long_string# concatenatehash = { key1: "val1", key2:
標籤:Optional ArgumentsSet default arguments, when we don‘t need to call it, we can simply skip it.def new_game(name, year=nil, system=nil) { name: name, year: year, system: system }endgame = new_game("Street Figher II") Options Hash
標籤:%QThis is an alternative for double-quoted strings, when you have more quote characters in a string.Instead of putting backslashes in front of them, you can easily write:>> %Q(Joe said: "Frank said: "#{what_frank_said}"")=> "Joe said:
標籤: 1 require ‘matrix‘ 2 3 class Matrix 4 def to_pretty_s 5 s = "" 6 i = 0 7 while i < self.column_size 8 s += "\n" if i != 0 9 j = 010 while j < self.row_size11