Ruby on Rails Guides: Contributing to Ruby on Rails
ぼやっと眺めてたら、公式のcoding rule(ガイドライン)が書いてありました。。
6.3 Follow the Coding Conventions
Rails follows a simple set of coding style conventions.
・Two spaces, no tabs (for indentation).
・No trailing whitespace. Blank lines should not have any spaces.
→これはvimだと分かるようにしているのですが、textmate2やsublime text2だと
やり方がわかんないなあ。
2012/10/7追記
sublime text2はTrailingSpacesというのがあるとコメント欄で教えていただきました。
package controlから導入可能です。
・Indent after private/protected.
→これもrailsは、こうなっているので、最近自分もこれに習うようにしています。
「インデントが1個足りないない!!」みたいに一瞬思うので、あんまり好きではないのですが、慣れでしょうか。
・Prefer &&/|| over and/or.
→そうですね。
・Prefer class << self over self.method for class methods.
・Use MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
・Use a = b and not a=b.
・Follow the conventions in the source you see used already.
The above are guidelines -- please use your best judgment in using them.
→まぁガイドラインですからね。