Skip to main content

Prerequisites

Before setting up your development environment, ensure you have:
  1. Docker Desktop - Download from docker.com
    • No subscription required, choose the free tier
    • Required for running the containerized application
  2. VS Code (Recommended) - For the best development experience with integrated tasks
  3. Git - For cloning and managing the repository
  4. .env file - Contains application secrets (contact developers for access)
The preferred and supported way to maintain a replicable development environment is with Docker. While you can set up your own environment without Docker, this is not covered in this documentation.

Initial Setup

First-Time Setup

  1. Clone the repository:
  1. Build the Docker containers:
  1. Obtain the .env file:
    • Contact the developers for the .env file containing application secrets
    • Place it in the root directory of the project
    • This file is not checked into version control for security reasons
  2. Start the containers:
  1. Initialize the database:
    • On first run, the database is automatically initialized with a single admin account: vp@sjaa.net
    • Sometimes this does not automatically happen and needs to be done manually:
  1. Access the application:
    • Navigate to https://127.0.0.1:3001
    • You’ll see a browser warning about the self-signed certificate
    • This is normal in development - click through the warning to proceed
The easiest way to run common development tasks is through VS Code’s built-in task runner. All tasks are pre-configured in .vscode/tasks.json and run commands inside the Docker container automatically.

Running Tasks

Access tasks through the Command Palette:
  1. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)
  2. Type “Tasks: Run Task
  3. Select from the list of available tasks
Or use the keyboard shortcut Cmd+Shift+B (macOS) or Ctrl+Shift+B (Windows/Linux) to run the default build task.

Available VS Code Tasks

Rails Console

Task Name: Rails Console Opens an interactive Rails console for debugging and exploring the application. What it does:
When to use:
  • Explore the database and ActiveRecord models
  • Test code snippets interactively
  • Debug data or relationships
  • Run one-off commands
Example session:

Run All Tests

Task Name: Run All Tests Runs the complete test suite (models, controllers, system tests). What it does:
When to use:
  • Before committing changes
  • After major refactoring
  • To ensure everything works together
  • CI/CD validation locally
Expected output:
  • Green dots (.) for passing tests
  • F for failures
  • E for errors
  • Final summary with test count and timing

Run Rails Tests

Task Name: Run Rails Tests Runs only unit and integration tests (excludes system tests for faster execution). What it does:
When to use:
  • Quick validation during development
  • Testing models and controllers only
  • Faster feedback loop than full test suite
Runs:
  • Model tests (test/models/)
  • Controller tests (test/controllers/)
  • Helper tests (test/helpers/)
  • Mailer tests (test/mailers/)

Run Single Test File

Task Name: Run Single Test File Runs tests from a specific file. VS Code prompts you to enter the test file path. What it does:
When to use:
  • Focused testing on specific functionality
  • Debugging a single failing test
  • Iterating on new test cases
  • Faster than running entire suite
Example paths:
  • test/models/person_test.rb
  • test/controllers/people_controller_test.rb
  • test/system/memberships_test.rb
Tip: You can also run a single test method:
(where 42 is the line number of the test method)

Run System Tests

Task Name: Run System Tests Runs browser-based integration tests using Capybara and Selenium. What it does:
When to use:
  • Testing full user workflows
  • Validating JavaScript interactions
  • End-to-end feature verification
  • Before deploying major UI changes
Note: System tests take longer as they start a headless browser for each test.

Start Rails Debug Server

Task Name: Start Rails Debug Server Starts the Rails server with remote debugging enabled on port 1234. What it does:
When to use:
  • When you need to set breakpoints in your code
  • Step-through debugging of complex logic
  • Inspecting variable state during execution
After starting:
  1. Set breakpoints in your code (click in the gutter)
  2. Open Run and Debug view (Cmd+Shift+D / Ctrl+Shift+D)
  3. Select “Attach to Rails (Docker)”
  4. Press F5 to attach the debugger
See Debugging section for detailed instructions.

Update Gemfile.lock

Task Name: Update Gemfile.lock Rebuilds the Docker image and extracts the updated Gemfile.lock after changing gems. What it does:
When to use:
  • After adding gems to Gemfile
  • After updating gem versions
  • After removing gems
Why this is necessary: The bind mount (./:/rails) overlays your local directory onto the container at runtime. The Gemfile.lock updated during build gets replaced by your local version. This task extracts it to keep them in sync.

Command-Line Tasks

If you prefer working directly with the command line, here are the essential commands:

Starting and Stopping

Database Operations

Running Tests

Background Jobs

Custom Rake Tasks

Updating Dependencies

When you update the Gemfile (add/remove/update gems):
Or use the VS Code task: “Update Gemfile.lock” (recommended)

Debugging

The application supports remote debugging using the debug gem with VS Code.

Starting a Debug Session

Option 1: VS Code Task (Recommended)
  1. Run the “Start Rails Debug Server” task
  2. Set breakpoints in your code (click in the gutter)
  3. Open Run and Debug view (Cmd+Shift+D / Ctrl+Shift+D)
  4. Select “Attach to Rails (Docker)”
  5. Press F5 to attach

VS Code Debug Configurations

Three debug configurations are available in .vscode/launch.json:
  1. Attach to Rails (Docker) - Primary option
  2. Debug Rails (Docker) - Alternative - Fallback option
  3. Connect to rdbg (Docker) - Direct rdbg connection

Troubleshooting Debugging

Problem: Can’t connect to debugger
  • Ensure port 1234 is not in use: lsof -i :1234
  • Check Docker logs: docker compose logs app
  • Verify debug gem is installed: docker compose run --rm app gem list debug
  • Restart containers: docker compose restart
Problem: Breakpoints not hitting
  • Ensure debug server is running
  • Verify breakpoint is in executed code path
  • Check that source maps are correctly configured
  • Try adding debugger statement directly in code

Common Workflows

Adding a New Feature

  1. Create a new branch:
  1. Make your changes in your editor
  2. Write tests for the new functionality
  3. Run tests using VS Code task “Run All Tests” or:
  1. Test manually in the browser at https://127.0.0.1:3001
  2. Commit and push:

Fixing a Bug

  1. Reproduce the bug in development environment
  2. Write a failing test that exposes the bug
  3. Use the debugger to understand what’s happening:
    • Add debugger statement where bug occurs
    • Run “Start Rails Debug Server” task
    • Attach debugger and step through code
  4. Fix the bug based on findings
  5. Verify test passes using “Run All Tests” task
  6. Commit the fix with descriptive message

Database Schema Changes

  1. Generate migration:
  1. Edit the migration file in db/migrate/
  2. Run the migration:
  1. Update models and tests to reflect schema changes
  2. Test thoroughly before committing

Adding or Updating Gems

  1. Edit Gemfile to add/update/remove gems
  2. Update Gemfile.lock using VS Code task “Update Gemfile.lock” or:
  1. Verify application still works
  2. Run tests to catch any issues
  3. Commit both Gemfile and Gemfile.lock

Best Practices

Container Management

Start containers in background:
Check container logs:
Restart after configuration changes:
Clean up unused containers/images:

Testing

Run tests frequently:
  • Use “Run Rails Tests” task during development (faster)
  • Use “Run All Tests” task before committing
  • Use “Run Single Test File” task when focusing on specific feature
Write tests first:
  • Test-driven development helps catch issues early
  • Tests serve as documentation
  • Easier to refactor with good test coverage
Keep tests fast:
  • Use fixtures or factories efficiently
  • Minimize database calls in tests
  • Run system tests only when needed

Database

Regular backups in development:
Reset when needed:
  • After major schema changes
  • When test data becomes inconsistent
  • Use VS Code task “Generate Test Data” after reset
Don’t commit .env:
  • Contains secrets and credentials
  • Already in .gitignore
  • Get from developers for legitimate use

Troubleshooting

Port Already in Use

Problem: Error about port 3001 or 5432 already in use Solution:

Database Connection Errors

Problem: Can’t connect to PostgreSQL database Solution:

Container Won’t Start

Problem: Docker container fails to start Solution:

Tests Failing

Problem: Tests that should pass are failing Solution:

Permission Errors

Problem: Permission denied errors when running commands Solution:
  • Ensure Docker Desktop has necessary permissions
  • On macOS: System Preferences → Security & Privacy
  • On Linux: Add user to docker group:
  • Log out and back in for changes to take effect

Browser Certificate Warning

Problem: Browser shows security warning at https://127.0.0.1:3001 Solution:
  • This is expected with self-signed certificates
  • Safe to click “Advanced” → “Proceed to localhost”
  • Warning doesn’t appear in production with valid certificate

Changes Not Reflecting

Problem: Code changes don’t appear in running application Solution:
Note: In development mode, most changes are auto-reloaded. If not:
  • Check for syntax errors in logs
  • Restart may be needed for initializers or routes
  • Clear browser cache for asset changes

Environment Variables

Key environment variables in .env file:
  • Database: DATABASE_URL, POSTGRES_USER, POSTGRES_PASSWORD
  • Rails: RAILS_ENV, SECRET_KEY_BASE
  • PayPal: PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET
  • Google: OAuth credentials for Calendar, Groups, Admin Directory
  • Email: SMTP settings for Gmail
Never commit .env to version control. It contains sensitive credentials.

Additional Resources

  • CLAUDE.md - AI assistant instructions and command reference
  • .vscode/tasks.json - VS Code task definitions
  • .vscode/launch.json - Debugger configurations
  • docker-compose.yml - Container orchestration
  • Dockerfile - Application container definition
  • README.md - Project overview and quick start

Summary

The development environment is containerized with Docker for consistency and ease of setup. VS Code tasks provide the recommended workflow for common operations like running tests, accessing the console, and debugging. For developers who prefer the command line, all tasks can also be run with docker compose and docker container exec commands. Key points:
  • Use Docker Desktop for environment management
  • Use VS Code tasks for the best developer experience
  • Run tests frequently during development
  • Use the debugger to understand complex issues
  • Keep containers and database in sync with migrations
  • Follow the documented workflows for common tasks