$ recombobulate _
home / tips / generate-ruby-on-rails-models-and-migrations-with-claude
45

Generate Ruby on Rails Models and Migrations with Claude

recombobulate @recombobulate · Mar 26, 2026 · Workflows
generate-ruby-on-rails-models-and-migrations-with-claude

Writing Rails migrations and models by hand means remembering column types, index syntax, and association macros every time. Claude can generate the whole stack from a plain-English description.

Create a Rails data model for a project management app with:
- Users (name, email, timestamps)
- Projects (belongs to user, name, description, status enum)
- Tasks (belongs to project, title, due_date, completed boolean)
- Add appropriate indexes and foreign keys

Claude will output migration files with the correct create_table syntax and a matching set of ActiveRecord models complete with belongs_to, has_many, validations, and scope suggestions. For enums, it will use Rails' built-in enum macro and suggest a sensible set of values.

It also knows to add null: false constraints and database-level indexes for foreign keys — the kind of detail that's easy to forget in a first pass.

# Claude-generated snippet
class Task < ApplicationRecord
  belongs_to :project
  scope :incomplete, -> { where(completed: false) }
  scope :overdue, -> { where("due_date < ?", Date.today).incomplete }
  validates :title, presence: true
end

You can follow up with "add a polymorphic comments association" or "generate factory_bot factories for all three models" to keep the momentum going.

Tell Claude what your domain looks like, and it'll give you Rails-ready code that follows conventions from migrations all the way to model validations.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 month ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 month ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 month ago