今、モデルがたくさんあるRailsアプリを開発している。基本的なモデリングは済んでいるが補助クラスが追加されたり関連が動いているので、RailLoadプラグインを使ってRailsのクラス関連図を出力してみる。Railsの場合has_many,belongs_to,has_oneなどで関連が定義されているのでこれを拾ってくれる仕組み。注意としてはモデル間でお互いに関連記述していないと関係を取得できない模様。親だけでなく子からも指定が必要。使っている限りでは自動で配置する機能が賢くて30モデルくらいでは全然問題ない。
詳しくは公式サイト参照。
- Windows用Graphvizをインストール http://www.graphviz.org/Download_windows.php
- gem install railroad
RaiLoad -Ruby on Rails diagrams generator-
RailRoad is a class diagrams generator for Ruby on Rails applications. It's a Ruby scriptthat loads the application classes and analyzes its properties (attributes, methods) and relationships (inheritance, model associations like has_many, etc.) The output is a graph description in the DOT language, suitable to be handled with tools like Graphviz.
RailRoad can produce:
Model diagrams, showing both inheritance hierarchy and models associations. You can choose to show the model "content columns" and its types.
Controller diagrams, showing inheritance hierarchy. You can include the controllers' methods, grouped by its visibility (public, protected, private.)
State machine diagramas (for use with the "acts_as_state_machine" plugin.)
エンタープライズ Rails著者:Dan Chak
販売元:オライリージャパン
発売日:2009-07-23
クチコミを見る