A Rails 8.0 application for managing running events with user registration, results tracking, and comprehensive admin tools.
- Event Management: Create and manage monthly 10km running events
- User Registration: Custom authentication with email confirmation
- Results Tracking: Record finish positions, times, and generate participant results
- Admin Dashboard: Comprehensive user and event management interface
- Email Notifications: Automatic result notifications when events are marked ready
- Volunteer Management: Track volunteer assignments and roles
- Barcode System: Generate unique barcodes for participant tracking
- Backend: Rails 8.0 with Ruby 3.3.4
- Database: SQLite (all environments)
- Frontend: Stimulus, Turbo, Tailwind CSS, Importmap
- Background Jobs: Solid Queue (runs in Puma process via
SOLID_QUEUE_IN_PUMA) - File Storage: Active Storage with SQLite
- Authentication: Custom session-based system (no Devise)
- Security: Cloudflare Turnstile CAPTCHA integration
- Event - Central entity representing running events with date, location, and number. Manages finish positions, times, and results
- User - Handles authentication and user management with email confirmation. Links to results and volunteer assignments
- Result - Links users to events with optional completion times and finish positions
- FinishPosition / FinishTime - Track event completion data separately for flexible result management
- Volunteer / Role / Assignment - Manage event staffing and user permissions (Administrator, Organiser)
- Email Notifications: Automatic result/participation emails when events are marked ready
- Admin Dashboard: Admin access controlled via
AdminAuthenticationconcern - Progressive Enhancement: Features work without JavaScript, enhanced with Stimulus controllers
- Responsive Design: Mobile-first interface using Tailwind CSS
- Clone the repository
- Install dependencies:
bundle install - Setup database:
bin/rails db:setup - Start development server:
bin/dev - Visit
http://localhost:3010
For a better development experience with custom domains:
- Install puma-dev:
brew install puma/puma/puma-dev - Setup system domains:
sudo puma-dev -setup - Install as service (with localhost domain):
puma-dev -install -d localhost - Configure project:
echo 3010 > ~/.puma-dev/ws10 - Start development server:
bin/dev - Visit
https://ws10.localhost(automatic HTTPS!)
Benefits: Clean URLs, automatic SSL certificates, multiple projects without port conflicts
bin/dev- Start Rails server and Tailwind watch processbin/rails console- Open Rails consolebin/rails test- Run test suite (excluding system tests)bin/rails test:system- Run system tests with Capybara/Seleniumbin/rails test:all- Run full test suite including system testsbin/brakeman- Run security analysisbin/rubocop- Run Ruby style linter
To work with real production data in development:
# Two-step process:
bin/rails db:dump # Download SQL dump from production (creates tmp/db.sql)
bin/rails db:restore # Restore from SQL dump to development
# Or combined:
bin/rails db:dump && bin/rails db:restore
# Restore development database from backup if needed
bin/rails db:restore_dev_backupSafety Features:
- Automatically backs up current development database before restore
- Timestamped backups stored in
tmp/development_backup_YYYYMMDD_HHMMSS.sqlite3 - Recovery available via
db:restore_dev_backuptask
Requirements:
- SSH access to production server (svr-02) using key-based authentication
- Production server configured in Kamal deployment
Email functionality uses Action Mailer with deliver_later for background processing. Event-related emails are triggered automatically when results_ready is set to true on an Event.
Development: Emails are blocked (delivery_method = :test) - no emails sent
Production: Uses configured SMTP settings for delivery
Uses Rails encrypted credentials for sensitive configuration. The application includes:
- Database configuration
- Email SMTP settings
- Cloudflare Turnstile keys
- Any API keys or secrets
Note: Never commit actual credentials to the repository.
When upgrading Rails or dependencies:
- Update
Gemfile - Run
bundle update - Run database migrations:
bin/rails db:migrate - Test migration reversibility:
bin/rails db:rollbackthenbin/rails db:migrate - Run full test suite:
bin/rails test:all - Update any deprecated code based on upgrade guides
Deployed using Kamal to a custom server with Cloudflare proxy:
- SSH access via public key to hostname specified in
config/deploy.yml(underservers->web) - Set
KAMAL_REGISTRY_PASSWORDenvironment variable (set -Ux KAMAL_REGISTRY_PASSWORD your_passwordin fish shell) - Cloudflare tunnel setup pointing to hostname specified in
config/deploy.yml(underproxy->host)
kamal setup- Initial deployment setupkamal deploy- Deploy application updateskamal console- Access production Rails consolekamal shell- SSH into production containerkamal logs- View production logs
- Uses persistent volumes for SQLite database and Active Storage
- Assets fingerprinted and served via Propshaft
- Background jobs processed via Solid Queue
- SSL handled by Cloudflare
- Custom Authentication: Session-based login system without external dependencies
- Email Confirmation: Users must confirm email addresses before full access
- Role-Based Access: Administrator and Organiser roles with different permission levels
- Admin Protection: Admin routes protected by
AdminAuthenticationconcern - Self-Protection: Users cannot delete themselves or remove their own admin roles
- CSRF Protection: Rails built-in CSRF protection enabled
- SQL Injection Protection: Parameterized queries and Active Record protections
- CAPTCHA Integration: Cloudflare Turnstile prevents automated abuse
- Secure Headers: Standard Rails security headers configured
- Password Security: Uses
has_secure_passwordwith bcrypt hashing - Session Security: Secure session configuration with appropriate timeouts
- No Secrets in Code: All sensitive data stored in Rails encrypted credentials
- Parameter Filtering: Sensitive parameters filtered from logs
- Input Validation: Comprehensive model validations and parameter permits
- Database Constraints: Database-level constraints complement Rails validations
- Security Scanning: Regular Brakeman security analysis in development