This repository provides a VS Code Dev Container setup for rapid Ruby on Rails development using Docker Compose. It includes a ready-to-use Ruby/Rails environment and a PostgreSQL database, plus a modern shell experience with Zsh and plugins.
- VS Code Dev Containers: Seamless development with Dev Containers.
- Docker Compose: Spins up both a Ruby/Rails development container and a PostgreSQL database container.
- Zsh & Plugins: Enjoy Zsh with Oh My Zsh, syntax highlighting, and autosuggestions.
- No Rails Project Included: Start your Rails app from scratch, choosing only the tools you need.
When you run rails new, you can choose to include or skip various tools and frameworks, such as:
- Tailwind CSS (
--css tailwind) - Bootstrap (
--css bootstrap) - Sass (
--css sass) - Stimulus (
--javascript esbuildor--javascript importmap) - Hotwire (Turbo & Stimulus, enabled by default)
- RSpec (add manually or via template)
- Minitest (default)
- Webpack (legacy, not recommended for new apps)
- Action Mailbox
- Action Text
- Active Storage
- System Tests
- API-only mode (
--api) - Skip Active Record (
--skip-active-record) - Skip Test (
--skip-test) - Skip Hotwire (
--skip-hotwire)
rails new <app_name> [options]— Create a new Rails apprails server— Start the Rails development serverrails console— Open the Rails consolerails db:create— Create the databaserails db:migrate— Run database migrationsrails generate <generator>— Generate code (models, controllers, etc.)rails testorrspec— Run tests
Inside the dev container terminal, run:
rails new . --database=postgresql --css=tailwindThis will:
- Create a new Rails app in the current directory
- Configure it to use PostgreSQL as the database
- Set up Tailwind CSS for styling
-
Open in VS Code Use "Open Folder in Container" or the "Reopen in Container" prompt.
-
Start Services Docker Compose will automatically start both the Rails and PostgreSQL containers.
-
Create Your Rails App Open a terminal in VS Code and run the recommended
rails newcommand above. -
Configure Database Update your
config/database.ymlif needed to match the PostgreSQL service settings. -
Enjoy Zsh The terminal uses Zsh with plugins for a modern shell experience.
- Go to the config/database.yml file
- in the default or any env, the credentiasl should looks like
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: <%= ENV['ENV_USERNAME'] %>
password: <%= ENV['ENV_PASSWORD'] %>
host: <%= ENV['ENV_HOST'] %>
port: 5432- create an .env file in root directory with this:
ENV_USERNAME=postgres
ENV_PASSWORD=postgres
ENV_HOST=localhost- and to the gemfile the next lines:
# Load environment variables from .env files
gem "dotenv-rails", groups: [ :development, :test ]- in the console type the next:
rails db:setup- and that's it, you now have setuped up the db
Tip:
You can customize your Rails app with additional options as needed. See rails new --help for more.