Railroad is a great UML tool for Ruby on Rails. It can automatically generate class diagrams of models and controllers.
For models, a railroad-generated class diagram shows attributes of each model and the associations between one model and another. A sample diagram can be found here. It is very useful for a developer to see attributes and associations of models. While attributes and associations reveal the inner states and relationships of models, methods specify their behaviours. They are all desirable in a class diagram. I would like railroad to generate a class diagram that also lists methods for models, which will help me to know what each model does. I know methods are displayed in a diagram that is generated for controllers, but I don’t see such an option for a diagram of models. Does someone know how to do that with railroad? Or is that possible?
Thanks!
Railroad does not add the model methods to the diagram. You can monkey patch the railroad code to get this feature.
Create a file called
rail_road_monkey_patch.rbinconfig/initializersdirectory and add the following code.Now you need a rake task to run railroad(you need this to ensure the patch is loaded).
Then,
rake doc:diagramsproducesdoc/models.svganddoc/controllers.svg. If you are on Windows, alter the rake task appropriately.Note 1: Rake task is taken from the
Railroadreadme.Note 2 I haven’t tested the code.