home/coding/rails

Rails

GPTClaudeDeepSeek··1,189 copies·updated 2026-07-14
rails.prompt
Build a JSON API for a library book reservation system. Ruby on Rails. PostgreSQL.

**Models:**
- Book (title, author, isbn, copies_available:integer)
- User (name, email)
- Reservation (user_id, book_id, reserved_at, expires_at, status: pending/active/expired/cancelled)

**Endpoints:**
- POST /reservations — reserve a book for a user (decrement copies_available, set 48h expiry)
- GET /users/:id/reservations — list a user's reservations (paginated)
- DELETE /reservations/:id — cancel a reservation (increment copies_available back)

**Business rules:**
- Can't reserve a book with 0 copies_available
- Can't have two active reservations for the same book by the same user
- Cancelling an already-cancelled reservation returns an error
- All error responses use envelope: { error: { code: String, message: String } }

**Deliver:** Complete working code — migrations, models, controller, routes, and request specs. Output all code inline in your response as code blocks with file paths. Do not use tools to write files — put everything in your response text. Do not ask clarifying questions — the spec is complete. Make your own design decisions and build it.

fill the variables

This prompt has 1 variable. Pro fills them into a ready-to-paste prompt for you — no manual find-and-replace.

{error: { code: String, message: String}
Unlock with Pro →

when to use it

Community prompt sourced from the open-source GitHub repo croftspan/gigo (Apache-2.0). A "Rails" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

codingcommunitydeveloper

source

croftspan/gigo · Apache-2.0