## Configure environment and secrets for Rails

### Summary
Configuration and secrets for a Rails app on Ample. Verified on Rails: an --env value delivered encrypted and reported as present without being echoed (secret=set). 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.

### 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)
- An Ample account token with servers:write

### Workflow Steps
1. **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; the server must bind 0.0.0.0 on PORT.

2. **Pass values on deploy**  
Use --env KEY=value (repeatable) or --env-file; values are encrypted at rest and reused on redeploys. Declare names only in ample.toml.  
**Command:** `ample deploy . --name  --public --env MY_SECRET=...`

3. **Verify**  
Fetch the live URL and /p/configuration-secrets on the example; on failure read the build and runtime logs.  
**Command:** `ample logs  --kind build`

### Tested Configuration
- **Template:** ruby-3.4  
- **Runtime:** ruby  
- **Size:** s-1vcpu-1gb  
- **Install Command:** `bundle config set --local path vendor/bundle && bundle config set --local without 'development test' && bundle install`  
- **Start Command:** `bundle exec rails server -b 0.0.0.0 -p $PORT`

### Costs
- **Currency:** USD  
- **Monthly Amount:** 5.0  
- **Basis:** size prices from pricing.toml (loaded by the API) at build revision 1ac5595375130d45290090e82ed0f554ccd45405-dirty
  
#### Cost Components
- **Name:** app server  
  - **Size:** s-1vcpu-1gb  
  - **Quantity:** 1.0  
  - **Monthly Amount:** 5.0  
  
### 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.

### Success Checks
- **Description:** app responds on its public URL  
  - **Kind:** http_get  
  - **Path:** /  
  - **Expect:** ample canary rails patterns  
- **Description:** configuration-secrets check from the example  
  - **Kind:** http_get  
  - **Path:** /p/configuration-secrets  
  - **Expect:** see the pattern fixture checks.

### Evidence Summary
- **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: an --env value delivered encrypted and reported as present without being echoed (secret=set).  
- **Observed At:** 2026-09-20T21:55:28Z  
- **Implementation Revision:** 4f7cb9813c1f-dirty (CLI 4f7cb98)  
- **Expires At:** 2027-03-19T21:55:28Z

### Next Actions
- **Browse the catalog index**  
  **Label:** Browse the catalog index  
  **Method:** GET  
  **Relative Path:** /v1/catalog

- **Search published recipes by intent, stack and constraints**  
  **Label:** Search published recipes by intent, stack and constraints  
  **Method:** POST  
  **Relative Path:** /v1/catalog/search  
  **Parameters:** {"body":{"limit":5,"query":"Configure environment and secrets for Rails"}}

- **Prepare a side-effect-free deployment plan for an authorized project**  
  **Label:** Prepare a side-effect-free deployment plan for an authorized project  
  **Method:** POST  
  **Relative Path:** /v1/catalog/plan  
  **Parameters:** {"body":{"inputs":{},"projectId":"","recipeId":"page:guides:rails:configuration-secrets","recipeRevision":"r1"}}

- **Read the existing agent authentication setup**  
  **Label:** Read the existing agent authentication setup  
  **Method:** GET  
  **Relative Path:** /mcp/setup

- **Browse Rails**  
  **Label:** Browse Rails  
  **Method:** GET  
  **Relative Path:** /v1/catalog/nodes/stack%3Aframework-rails

- **Browse Configure deployment**  
  **Label:** Browse Configure deployment  
  **Method:** GET  
  **Relative Path:** /v1/catalog/nodes/intent%3Aconfigure-deployment

- **Browse Public web service**  
  **Label:** Browse Public web service  
  **Method:** GET  
  **Relative Path:** /v1/catalog/nodes/pattern%3Apublic-web-service
