Skip to content

Instantly share code, notes, and snippets.

@overdrivemachines
Last active October 17, 2021 02:46
Show Gist options
  • Save overdrivemachines/d0d53e2bbfa7ff00e9aa2a40446a26be to your computer and use it in GitHub Desktop.
Save overdrivemachines/d0d53e2bbfa7ff00e9aa2a40446a26be to your computer and use it in GitHub Desktop.
Ruby on Rails 6.1 Cheat Sheet

Ruby on Rails 6.1 Cheat Sheet

Naming Conventions

Filename: snake_case, orders_controller.rb
Classes: CamelCase, ApplicationController, 'PropertiesController'
Variables: snake_case, order_amount, total, var1
Methods: snake_case, index, create, save! (operates destructively or raise an exception instead of failing), empty? (returns bool value)
Database Tables: snake_case plural: users, orders, bigfoot_sightings
Model: CamelCase singular: User, Order, BigfootSighting

Datatypes

- :primary_key
- :string - :text
- :integer - :bigint - :float - :decimal
- :numeric
- :datetime - :date - :time
- :binary
- :boolean

Generators

$ rails g model user name:string{30} username:string:uniq weight:decimal{4,1} office:references

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment