Reputation: 171509
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?
Upvotes: 16
Views: 10005
Reputation: 303559
Yes, two spaces per indentation level is the Ruby community standard.
Upvotes: 27
Reputation: 864
Yes, I always indent 2 spaces instead of tabs. It looks a little nicer.
Rails itself uses the same convention.
Upvotes: 1