LoginSignup
0
0

More than 5 years have passed since last update.

Railsのテーブル構成を見る

Posted at

annotateというgemを使いました。

いつ、どうして使ったか

保守されていないアプリケーションの機能改善などでエンティティの定義を知りたい時にクライアントツールを使って確認するのが大変だった。

導入方法

Readmeに記載がある通りにGemfileに追記。

Gemfile
group :development do
  gem 'annotate'
end

migration時に自動で実行する

rails g annotate:install を実行すると lib/tasks/auto_annotate_models.rake というrakeタスクが生成され、 migration時に実行されるようになる。

その他の設定

ファイルの最下部にアノテーションしたいので設定を before から after に変更

lib/tasks/auto_annotate_models.rake
      'position_in_routes'        => 'after',
      'position_in_class'         => 'after',
      'position_in_test'          => 'after',
      'position_in_fixture'       => 'after',
      'position_in_factory'       => 'after',
      'position_in_serializer'    => 'after',

補足

ファイルに不要な記述が増えるのでmigrationの実行が少しだけ遅くなる、ファイルの容量が大きくなります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0