1. Create a repo in Github
  2. Install last version of ruby:

    rbenv install 3.0.0
    rbenv global 3.0.0
  3. Install last version of node.js: nvm is equivalent to rbenv: allow to manage several versions of node.js on the same computer. Versions are set on a per-project basis.

    nvm install node
    nvm alias default node
    nvm use
    node --version
  4. Install rails

    gem install rails
  5. Bootstrap a new app.

    rails new my-app \
     --database=postgresql \
     --api \
  6. Set the NodeJS version in our new app.

    cd my-app
    echo "15.8.0" > .nvmrc
  7. Let’s check the used ruby version.

    cat .ruby-version
  8. Push to Github

    git remote add origin git@github.com:<USER>/<REPO>.git
    git commit -m "first commit"
  9. Test run the app

    bundle exec rails s
  10. I want to use PostgreSQL and avoid manually installing the database by using Docker-Compose. Create and configure Docker:

    version: "3.7"
        image: "postgres" # use latest official postgres version
          - ""
          POSTGRES_USER: ${USER}
          POSTGRES_HOST_AUTH_METHOD: "trust"
          - ${PWD}/db:${PWD}/db # persist data even if container shuts downvolumes:
          test: ["CMD", "pg_isready", "-U", "${USER}"]
        container_name: quiz_postgres
  11. Install postgresql and disable it.

    sudo apt install postgresql
    sudo systemctl disable postgresql
    sudo systemctl stop postgresql
  12. Launch docker and connect to the DB:

    docker-compose up -d
    psql -h -U <USER> # Connect to the DB directly
    docker-compose run database bash # Or connect inside the docker container...
    psql -h database -U <USER> # ...and then to the DB
  13. Next time you want to start or stop docker, don’t do up but instead do:

    docker-compose stop
    docker-compose start
  14. Edit database.yml:
default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

  <<: *default
  url: <%= "postgres://#{ENV['USER']}:@localhost:5432/quiz-development" %>

  <<: *default
  url: <%= "postgres://#{ENV['USER']}:@localhost:5432/quiz-test" %>
  1. Start rails and create a db:

    bundle exec rails db:create
    bundle exec rails db:migrate
    bundle exec rails s