Ruby Gem - Annotate

October 22, 2012

Annotate adds schema information into model file.

We will annotate schema information for User model in example below.

Open a terminal, at project directory, run:

  $ bundle exec annotate User

Schema information is added on top of /<project>/app/model/User.rb:

  # == Schema Information
  #
  # Table name: users
  #
  #  id              :integer          not null, primary key
  #  name            :string(255)
  #  email           :string(255)
  #  created_at      :datetime         not null
  #  updated_at      :datetime         not null
  #  password_digest :string(255)
  #  remember_token  :string(255)
  #  admin           :boolean          default(FALSE)

Every time the model changed, rerun the command to update the new schema information.

Discussion, links and tweets

We craft apps and make things easier.