The railway does not add model methods to the diagram. You can monkey fix the rail code to get this feature.
Create a file with a name rail_road_monkey_patch.rbin the directory config/initializersand add the following code.
require 'app_diagram'
class ModelsDiagram
alias_method_chain :process_class, :methods
def process_class_with_methods(current_class)
if current_class.is_a? Class
na = {:public => [], :protected => [], :private => []}
na[:public] = current_class.public_instance_methods(false).sort unless @options.hide_public
na[:protected] = current_class.protected_instance_methods(false).sort unless @options.hide_protected
na[:private] = current_class.private_instance_methods(false).sort unless @options.hide_private
@graph.add_node ['model', current_class.name, na]
end
process_class_without_methods(current_class)
end
end
Now you need a rake task to run the railway (this is necessary to ensure that the patch is loaded).
namespace :doc do
namespace :diagram do
task :models => :environment do
sh "railroad -i -l -a -m -M | dot -Tsvg | sed 's/font-size:14.00/font-size:11.00/g' > doc/models.svg"
end
task :controllers => :environment do
sh "railroad -i -l -C | neato -Tsvg | sed 's/font-size:14.00/font-size:11.00/g' > doc/controllers.svg"
end
end
task :diagrams => %w(diagram:models diagram:controllers)
end
Then rake doc:diagramscreates doc/models.svgand doc/controllers.svg. If you are on Windows, change the rake task accordingly.
Note 1 : The Rake task is taken from Railroadreadme.
Note 2 I have not tested the code.
source
share