LoginSignup
1
2

More than 5 years have passed since last update.

rails-erdを使いER図を作る時に詰まったのでMEMO

Posted at

まずはrails-erdを使うために必要なpraphivizをインストール

terminal
$ apt-get install graphviz
# or
$ brew install graphviz

gemをインストール

gemfile
group :development do
  gem 'rails-erd'
end

dotファイルを作成

terminal
$ erd --inheritance --direct --attributes=foreign_keys,content --filetype=dot

--attributes=〇〇でカラムをカスタマイズできます。
--filetype=〇〇で作成するファイルのタイプを決められます。

今回の場合はerd.dotが作成されます。

dotファイルを開く

terminal
$ open erd.dot

dotファイルをpngに変換

エラーか何かでdotファイルを開けなかったのでpngファイルに変換します。

terminal
dot -Tpng erd.dot -o erd.png

以上です。ありがとうございました。

1
2
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
1
2