finds.dev

ctran/annotate_models

Annotate Rails classes with schema and routes info

View on GitHub

★ 4,490RubyNOASSERTIONupdated Aug 2024

// the take

annotate_models writes a comment block at the top or bottom of your ActiveRecord model files showing the current database schema — column names, types, indexes, foreign keys. It also optionally annotates routes.rb with `rake routes` output. Rails shops use it to avoid context-switching to db/schema.rb every time they want to know what columns a model has.

Hooks into db:migrate automatically so annotations stay current without a manual step. The --show-indexes and --show-foreign-keys flags surface constraints that are otherwise invisible in day-to-day model editing. Supports factories, fixtures, serializers, and custom paths via --additional-file-patterns, so the schema comment lives next to every artifact that cares about it. The --frozen flag lets CI reject unannotated or stale annotations, which is a useful guardrail.

Last push was August 2024 and activity has been thin for a couple of years — open issues pile up without much triage. The WARNING in the README is real and undersells the risk: any leading comment block that looks like a prior annotation gets silently blown away, which bites you if you've manually added notes above the class. No support for non-ActiveRecord ORMs or databases that aren't Postgres/MySQL/SQLite. The routes annotation ages out fast and tends to create noisy diffs in repos with many routes, making it more trouble than it's worth.

We read the README, the directory tree and a key source file in July 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
4,490
Forks
683
Language
Ruby
License
NOASSERTION
Last commit
5 Aug 2024

// nearby

If annotate_models isn't quite it.

All repos →