开发者

What's the proper style to indent Ruby on Rails code?

I've noticed that Ruby on Rails code has 2 spaces indentation, e.g.:开发者_JAVA百科

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      ...
      t.timestamps
    end
  end
  ...
end

Is this a convention to have 2 spaces ? (I've used to indent with Tab, which is usually 4 spaces.)

Bonus: Does anyone know how to change the Tab size from 4 spaces to 2 spaces in e text editor?


Yes, two spaces per indentation level is the Ruby community standard.


Yes, I always indent 2 spaces instead of tabs. It looks a little nicer.

Rails itself uses the same convention.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜