Rails port/Railroad diagrams

From OpenStreetMap Wiki
Jump to navigation Jump to search

Railroad [1] is a rubyforge project which gives nice diagrams of the rails port on openstreetmap. You require to have got the rails port running on whichever machine you are running this tool. You install railroad by running the command

 sudo gem install railroad.

Models

It appears that railroad tries to access the database tables for the model object GeoRecord. As this is a parent object which is not stored in the database, you have to tell railroad to ignore it.

The most simple diagram can be produced using the following command:

 railroad -e app/models/geo_record -o models.dot -M

You can then use dot to produce the diagram

 dot -Tpng models.dot >models.png

Using the -l switch in the railroad command, you get a label telling you when the diagram was produce, with the version of the schema.

The diagram below was built using the following commands:

 railroad -l -a -j -t -i -e app/models/geo_record.rb -o models.dot -M 
 dot -Tpng models.dot >models.png
The models in the rails port


Controllers

You can create a diagram showing all the controllers in osm.

 railroad -o controllers.dot -C

You can then use neato to produce the image diagram

 neato -Tpn controllers.dot >controllers.png

(The above commands can be done in one step piped together).

Using the -l switch in the railroad command, you get a label telling you when the diagram was produce, with the version of the schema.

I used the following commands to create the diagram below:

 railroad -l -o controllers.dot -C
 neato -Tpng controllers.dot >controllers.png
The controllers in the rails port