- Methods should be sorted alphabeticaly
class Plop
def some_method
#...
end
# Ruby 2.1
private def some_private_method
# ...
end
# Ruby < 2.1
def some_private_method
# ...
end
private :some_private_method
def self.some_private_class_method
# ...
end
private_class_method :some_private_class_method
end
# ruby requires
class ClassName < ActiveRecord::Base
# constants
# extends/includes
# callbacks
# attr_accessors
# associations
# delegates
# extra capabilities
# accepts_nested_attributes_for
# validations
# scopes
# other definition such as alias_method
# class methods
# instance methods
end
- Fields and validators should be sorted alphabeticaly
class ClassName < ActiveRecord::Base
validates :field,
length: { in: 1..100 },
presence: true
validates :other_field,
length: { in: 1..100 },
numericality: { only_integer: true },
presence: true
end