{"catalogRevision":"cat_f13ab9a494120b5e","recipeId":"page:guides:rails:database-connection","recipeRevision":"r1","canonicalPath":"/guides/rails/database-connection","label":"Connect Postgres for Rails","family":"Framework operation","summary":"Database connection for a Rails app on Ample. Verified on Rails: a managed PostgreSQL database auto-provisioned and injected as DATABASE_URL, with real queries succeeding at request time (records=ok). Build and start: bundle install into vendor/bundle from Gemfile.lock (development and test groups skipped), then Puma via `rails server` reading PORT on the ruby-3.4 template with RAILS_ENV=production.","representativeQueries":["Connect Postgres for Rails","Where can I host Connect Postgres built with Rails?","I need driver setup, connection settings, secret handling and a real connection test."],"breadcrumbIds":["discovery","stack","stack:frameworks","stack:framework-rails","page:guides:rails:database-connection"],"breadcrumbs":[{"id":"discovery","label":"Agent hosting discovery","canonicalPath":"/discover/discovery","kind":"root"},{"id":"stack","label":"Frameworks and execution targets","canonicalPath":"/discover/stack","kind":"facet"},{"id":"stack:frameworks","label":"Frameworks","canonicalPath":"/discover/stack/frameworks","kind":"group"},{"id":"stack:framework-rails","label":"Rails","canonicalPath":"/discover/stack/framework-rails","kind":"atom"},{"id":"page:guides:rails:database-connection","label":"Connect Postgres for Rails","canonicalPath":"/guides/rails/database-connection","kind":"recipe"}],"parentIds":["stack:framework-rails","intent:connect-app-to-database","pattern:relational-records"],"parents":[{"id":"stack:framework-rails","label":"Rails","canonicalPath":"/discover/stack/framework-rails","kind":"atom"},{"id":"intent:connect-app-to-database","label":"Connect app to database","canonicalPath":"/discover/intent/connect-app-to-database","kind":"atom"},{"id":"pattern:relational-records","label":"Relational records","canonicalPath":"/discover/pattern/relational-records","kind":"atom"}],"resourceRequirements":["primitive:compute","primitive:postgres"],"infrastructureRequirements":[{"primitiveId":"primitive:compute","label":"Compute","canonicalPath":"/discover/primitive/compute","status":"verified","summary":"Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes."},{"primitiveId":"primitive:postgres","label":"Postgres","canonicalPath":"/discover/primitive/postgres","status":"verified","summary":"Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied."}],"framework":"Rails","workload":"Connect Postgres","releaseStatus":"published","supportStatus":"verified","executionStatus":"ready","docsOnly":false,"prerequisites":["A Rails project (bundle install into vendor/bundle from Gemfile.lock (development and test groups skipped), then Puma via `rails server` reading PORT on the ruby-3.4 template with RAILS_ENV=production)","A PostgreSQL driver reading DATABASE_URL at runtime","An Ample account token with servers:write, databases:read"],"testedConfiguration":{"template":"ruby-3.4","runtime":"ruby","size":"s-1vcpu-1gb","install":"bundle config set --local path vendor/bundle && bundle config set --local without 'development test' && bundle install","start":"bundle exec rails server -b 0.0.0.0 -p $PORT"},"inputSchema":{"additionalProperties":false,"properties":{"env":{"description":"Encrypted environment variables","items":{"pattern":"^[A-Z][A-Z0-9_]*=.*$","type":"string"},"maxItems":50,"type":"array"},"name":{"description":"App name","maxLength":63,"minLength":1,"pattern":"^[a-z0-9-]+$","type":"string"},"path":{"description":"Project directory or ample.toml service","maxLength":512,"minLength":1,"type":"string"},"release_command":{"description":"Migration command run before activation","maxLength":512,"type":"string"}},"required":["name","path"],"type":"object"},"outputSchema":null,"workflowSteps":[{"title":"Build and start","body":"bundle install into vendor/bundle from Gemfile.lock (development and test groups skipped), then Puma via `rails server` reading PORT on the ruby-3.4 template with RAILS_ENV=production; the server must bind 0.0.0.0 on PORT."},{"title":"Read DATABASE_URL at runtime","body":"Open connections from the environment inside handlers or a pool; omit DATABASE_URL to auto-provision a managed database or pass --env DATABASE_URL=... for an existing one."},{"title":"Verify","body":"Fetch the live URL and /p/relational-records on the example; on failure read the build and runtime logs.","command":"ample logs <deployment_id> --kind build"}],"examples":[{"title":"Rails pattern fixture","description":"Verified database connection on Rails.","sourceRef":"tests/deploy-canaries/rails-patterns"}],"successChecks":[{"description":"app responds on its public URL","kind":"http_get","path":"/","expect":"ample canary rails patterns"},{"description":"relational-records check from the example","kind":"http_get","path":"/p/relational-records","expect":"see the pattern fixture checks"}],"limitations":["Verified on the ruby-3.4 template at s-1vcpu-1gb; other sizes and Rails major versions are not verified.","Region, compliance attestations and request-duration limits are unknown and not claimed.","Managed PostgreSQL 16 only; extensions, connection limits and backup or restore procedures are not verified."],"costEstimate":{"currency":"USD","monthlyAmount":10.0,"authoritative":true,"basis":"size prices from pricing.toml (loaded by the API) at build revision 115ee02ebdf5c12b2d74e3064d4a52b3b1102944","components":[{"name":"app server","size":"s-1vcpu-1gb","quantity":1.0,"monthlyAmount":5.0},{"name":"managed PostgreSQL database","size":"s-1vcpu-1gb","quantity":1.0,"monthlyAmount":5.0}],"note":"Always-on monthly price of the tested sizes; apps auto-pause when idle. Buckets are allocation-priced per quota and not included."},"evidenceSummary":[{"kind":"canary_run","summary":"Rails pattern fixture deployed on Ample (bundle install into vendor/bundle from Gemfile.lock (development and test groups skipped), then Puma via `rails server` reading PORT on the ruby-3.4 template with RAILS_ENV=production); for this guide: a managed PostgreSQL database auto-provisioned and injected as DATABASE_URL, with real queries succeeding at request time (records=ok).","observedAt":"2026-09-20T21:55:28Z","implementationRevision":"4f7cb9813c1f (CLI 4f7cb98)","expiresAt":"2027-03-19T21:55:28Z","scope":{"checks":["/p/relational-records"],"template":"ruby-3.4"}}],"lastVerifiedAt":"2026-09-20T21:55:28Z","mcpBinding":{"registryRef":"mcp:ample_deploy","toolName":"ample_deploy","schemaHash":"876465fce906da0c224d62961d3343064108ebe30af80cf1b87094974e948853","observedAt":"2026-09-22T00:31:22.774679+00:00","implementationRevision":"e6446ceea69b","requiredScopes":["servers:write","databases:read"],"bindingState":"current"},"unknowns":["region availability is unknown until a verified region fact is recorded","compliance attestations are unknown; none are claimed"],"formats":{"html":"https://ample.computer/guides/rails/database-connection","markdown":"https://ample.computer/guides/rails/database-connection.md","json":"https://api.ample.computer/v1/catalog/recipes/page%3Aguides%3Arails%3Adatabase-connection"},"nextActions":[{"actionId":"browse-catalog","label":"Browse the catalog index","operationId":"catalog_index","method":"GET","relativePath":"/v1/catalog","origin":"api","parameters":{},"requiresAuthentication":false,"requiresApproval":false},{"actionId":"search-recipes","label":"Search published recipes by intent, stack and constraints","operationId":"search_recipes","method":"POST","relativePath":"/v1/catalog/search","origin":"api","parameters":{"body":{"limit":5,"query":"Connect Postgres for Rails"}},"requiresAuthentication":false,"requiresApproval":false},{"actionId":"plan:page:guides:rails:database-connection","label":"Prepare a side-effect-free deployment plan for an authorized project","operationId":"plan_deployment","method":"POST","relativePath":"/v1/catalog/plan","origin":"api","parameters":{"body":{"inputs":{},"projectId":"<workspace or server id you own>","recipeId":"page:guides:rails:database-connection","recipeRevision":"r1"}},"requiresAuthentication":true,"requiresApproval":false},{"actionId":"auth-setup","label":"Read the existing agent authentication setup","operationId":"existing_auth_setup","method":"GET","relativePath":"/mcp/setup","origin":"api","parameters":{},"requiresAuthentication":false,"requiresApproval":false},{"actionId":"browse:stack:framework-rails","label":"Browse Rails","operationId":"browse_node","method":"GET","relativePath":"/v1/catalog/nodes/stack%3Aframework-rails","origin":"api","parameters":{"nodeId":"stack:framework-rails"},"requiresAuthentication":false,"requiresApproval":false},{"actionId":"browse:intent:connect-app-to-database","label":"Browse Connect app to database","operationId":"browse_node","method":"GET","relativePath":"/v1/catalog/nodes/intent%3Aconnect-app-to-database","origin":"api","parameters":{"nodeId":"intent:connect-app-to-database"},"requiresAuthentication":false,"requiresApproval":false},{"actionId":"browse:pattern:relational-records","label":"Browse Relational records","operationId":"browse_node","method":"GET","relativePath":"/v1/catalog/nodes/pattern%3Arelational-records","origin":"api","parameters":{"nodeId":"pattern:relational-records"},"requiresAuthentication":false,"requiresApproval":false}]}