Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.:

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?

like image 908
Misha Moroshko Avatar asked Dec 07 '10 23:12

Misha Moroshko


1 Answers

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

like image 149
Phrogz Avatar answered Sep 28 '22 07:09

Phrogz