Skip to content

Instantly share code, notes, and snippets.

@fernandoacorreia
Last active September 30, 2023 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandoacorreia/bc7d57e18f3cad913fd32b35fa2341e6 to your computer and use it in GitHub Desktop.
Save fernandoacorreia/bc7d57e18f3cad913fd32b35fa2341e6 to your computer and use it in GitHub Desktop.
Ruby on Rails cheat sheet

Ruby on Rails cheat sheet

Creating apps

Creating a new app from Jumpstart Pro Rails Template:

take my_app
git init
git remote add upstream git@github.com:jumpstart-pro/jumpstart-pro-rails.git
git fetch --all
git checkout -b main
git reset --hard upstream/main
git remote add origin git@github.com:my_org/my_app.git
git push -u origin main

Install dependencies from Brewfile:

brew bundle install --no-upgrade

Start the database servers:

brew services start postgresql
brew services start redis

Generating scaffold

bin/rails g scaffold books title:string author:string publication_year:integer

Migrate the database

bin/rails db:migrate

Ading a new gem

  1. Add the gem to Gemfile.
  2. Run bundle install.
  3. Commit Gemfile and Gemfile.lock.
  4. Require the gem e.g. in config/application.rb.
  5. Configure the gem.
  6. Migrate the database.
  7. Restart the server.
  8. Run tests.

Fix formatting

standardrb --fix

Seed the database

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