Auto-add schema comment blocks to Rails model files each time you run a migration.
Annotate test files, fixtures, and factory files so database column names are visible when writing tests.
Add a routes summary comment to routes.rb for quick URL reference without running rake routes.
Annotate is a Ruby gem for Rails applications that automatically adds a comment block to your model files showing the current database table structure. When your database has a table called "line_items" with columns like id, quantity, and product_id, running the annotate command inserts a comment at the top or bottom of your model file that lists those columns along with their data types. This means you can see the database schema without leaving your code editor or running a separate query. Beyond model files, it can add the same kind of schema comments to related files: test files, fixture files, and factory files used by testing libraries like factory_bot. It can also annotate your routes.rb file with the full output of rake routes, giving you a quick reference to your app's URL structure right inside that file. Annotate integrates with Rails migrations. Once configured, it runs automatically every time you run a database migration, so your schema comments stay up to date without any manual step. You can also run it on demand from the command line, and there is a delete option to remove all annotations if you want to clean them out. Configuration is handled through a generated rake file where you can control whether annotations go at the top or bottom of files, which types of files get annotated, and whether the automatic post-migration run is active. Individual files can opt out by including a special comment string anywhere in the file. The gem is intended for development use only and is listed in the development group in a Gemfile. It supports geometric column types used with spatial database adapters like PostGIS, annotating them with geometry type and spatial reference information. Outside Rails, it can be used with explicit options pointing to your model directories.
← ctran on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.