Ruby on Rails 8 cheatsheet

Ruby on Rails 8: Getting started

11 common Ruby on Rails 8 tasks.

Install Rails

Install the Rails gem. Needs Ruby installed.

gem install rails

Check the Rails version

Print the installed Rails version.

rails --version

Create an app

Generate a new Rails application in a folder named myapp.

rails new myapp

Create an app that uses PostgreSQL

Choose a database other than the default SQLite.

rails new myapp --database=postgresql

Create an API-only app

Skip the view layer and middleware that browser apps need.

rails new myapi --api

Install the gems

Install the gems listed in the Gemfile.

bundle install

Start the development server

Run the app at http://localhost:3000.

bin/rails server

Start the server on another port

Use a different port when 3000 is taken.

bin/rails server -p 4000

Open the Rails console

Start an IRB session with the app loaded. Handy for trying out models.

bin/rails console

List the routes

Show every route, with the controller action it maps to.

bin/rails routes

Show app and environment details

Print the Ruby, Rails and database versions and the environment.

bin/rails about

Was this page helpful?