annotateでschemeをmodelに書き出す
Gemfile
group :development do gem 'annotate' end
bundle install
使い方
bundle exec annotate
テーブルの情報がコメントで記載されます
# == Schema Information # # Table name: areas # # id :bigint(8) not null, primary key # name :string not null # description :string # created_at :datetime not null # updated_at :datetime not null # prefecture_id :integer # class Area < ApplicationRecord # ------------------------------------------------------------------------------- # Relations # ------------------------------------------------------------------------------- extend ActiveHash::Associations::ActiveRecordExtensions belongs_to :prefecture # ------------------------------------------------------------------------------- # Validations # ------------------------------------------------------------------------------- validates :name, presence: true end