Rails API for TEEEM application.
# Install dependencies
bundle install
# Create database
rails db:create
# Run migrations
rails db:migrate
# Seed database (optional)
rails db:seed
# Start server
rails serverThe API will be available at http://localhost:3000.
PostgreSQL is used for all environments. Configure in config/database.yml.
CORS is configured in config/initializers/cors.rb. Set allowed origins via the CORS_ORIGINS environment variable:
export CORS_ORIGINS=http://localhost:5173,https://your-app.vercel.appAdd your API routes in config/routes.rb.
Example:
Rails.application.routes.draw do
namespace :api do
namespace :v1 do
resources :items
end
end
end# Login to Heroku
heroku login
# Create app
heroku create your-app-name
# Add PostgreSQL
heroku addons:create heroku-postgresql:essential-0
# Set environment variables
heroku config:set RAILS_ENV=production
heroku config:set CORS_ORIGINS=https://your-frontend.vercel.app
# Deploy
git push heroku main
# Run migrations
heroku run rails db:migrateRails uses Minitest by default (skipped in this setup). To add tests:
# Add to Gemfile
gem "minitest-rails"
# Run tests
rails testDATABASE_URL- PostgreSQL connection stringRAILS_ENV- Rails environment (development/production)CORS_ORIGINS- Comma-separated list of allowed originsSECRET_KEY_BASE- Secret for sessions (generate withrails secret)