← Home
annotate

Rails Generate annotate:install

Reference & Command Builder

Published: 2023-07-11
Author: Harrison Broadbent
Type: Reference & Command Builder

Rails Generate Annotate:Install

Rails Generate Annotate:Install (rails g annotate:install) is the setup generator for the Annotate gem.

The Annotate gem is brilliant! It adds schema information to the top of each model file, which makes it much easier to check what attributes and types each model has.

Rather than a bare model file like this —

# app/models/user.rb
#
class User < ApplicationRecord
  ...
end

You get schema annotations like this —

# app/models/user.rb
 
# == Schema Information
#
# Table name: users
#
#  id                     :bigint           not null, primary key
#  name                   :string
#  created_at             :datetime         not null
#  updated_at             :datetime         not null
#
class User < ApplicationRecord
  ...
end

Command Builder for rails g annotate:install

rails g annotate:install 

Generator Options

Runtime Options

# Command Options
❯ rails g annotate:install

Usage:
  bin/rails generate annotate:install [options]

Options:
  [--skip-namespace], [--no-skip-namespace]              # Skip namespace (affects only isolated engines)
                                                         # Default: false
  [--skip-collision-check], [--no-skip-collision-check]  # Skip collision check
                                                         # Default: false

Runtime options:
  -f, [--force]                    # Overwrite files that already exist
  -p, [--pretend], [--no-pretend]  # Run but do not make any changes
  -q, [--quiet], [--no-quiet]      # Suppress status output
  -s, [--skip], [--no-skip]        # Skip files that already exist

# Command Description
Description:
  Copy annotate_models rakefiles for automatic annotation