[Ruby on Rails (RoR)] The Ruby on Rails (RoR) Style Guide

Introduction

Role models are important.

— Officer Alex J. Murphy / RoboCop

The goal of this guide is to present a set of best practices and style prescriptions for Ruby on Rails 4 development. It’s a complementary guide to the already existing community-driven Ruby coding style guide.

This Rails style guide recommends best practices so that real-world Rails programmers can write code that can be maintained by other real-world Rails programmers. A style guide that reflects real-world usage gets used, and a style guide that holds to an ideal that has been rejected by the people it is supposed to help risks not getting used at all - no matter how good it is.

The guide is separated into several sections of related rules. I’ve tried to add the rationale behind the rules (if it’s omitted I’ve assumed it’s pretty obvious).

References

[1] The Rails Style Guide - https://rails.rubystyle.guide/

[2] rubocop-hq/rubocop-rails: A RuboCop extension focused on enforcing Rails best practices and coding conventions. - https://github.com/rubocop-hq/rubocop-rails

[3] rubocop-hq/rails-style-guide: A community-driven Ruby on Rails style guide - https://github.com/rubocop-hq/rails-style-guide

[4] rubocop-hq/ruby-style-guide: A community-driven Ruby coding style guide - https://github.com/rubocop-hq/ruby-style-guide

[5] Style guides | GitLab - https://docs.gitlab.com/ee/development/contributing/style_guides.html

[6] Ruby Style Guide - https://shopify.github.io/ruby-style-guide/

[7] airbnb/ruby: Ruby Style Guide - https://github.com/airbnb/ruby

[8] GitHub Guides - https://guides.github.com/

[9] The Twelve-Factor App - https://12factor.net/