Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 772877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:52:25+00:00 2026-05-14T18:52:25+00:00

Railroad is a great UML tool for Ruby on Rails. It can automatically generate

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:52:26+00:00Added an answer on May 14, 2026 at 6:52 pm

    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.rb in config/initializers directory and add the following code.

    require 'app_diagram'
    
    # RailRoad models 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 railroad(you need this to ensure 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:diagrams produces doc/models.svg and doc/controllers.svg. If you are on Windows, alter the rake task appropriately.

    Note 1: Rake task is taken from the Railroad readme.

    Note 2 I haven’t tested the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.