Project

rails_map

0.0
The project is in a healthy, maintained state
RailsMap automatically generates beautiful, interactive API documentation for your Rails application. Features: • Live documentation via Rails Engine at /rails-map • Static HTML generation for offline use • Automatic parameter detection (path, query, body) • Route documentation with HTTP methods and paths • Controller documentation with actions and parameters • Model documentation with columns, associations, validations, and scopes • Built-in authentication support • Customizable themes and colors • Zero configuration - just install and go! Perfect for API development, team collaboration, and maintaining up-to-date documentation.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.0
~> 13.0
~> 3.0

Runtime

>= 5.0, < 8.0
 Project Readme

Rails Map

Gem Version Downloads License Ruby Rails

🌐 Homepage | 📦 RubyGems | 🐙 GitHub

Automatically generates interactive API documentation for Rails by mapping routes, controllers, and models. Zero configuration—just install and go.

  • Routes - All routes grouped by controller with HTTP methods, paths, and route names
  • Controllers - Separate page for each controller with detailed route information
  • Models - Separate page for each model with columns, associations, validations, and scopes

Installation

Add this line to your application's Gemfile:

gem 'rails_map'

And then execute:

bundle install

Quick Setup (With Authentication - Default)

Run the installer:

rails g rails_map:install

Set environment variables (optional):

export RAILS_MAP_USERNAME=admin
export RAILS_MAP_PASSWORD=your_secure_password

Or add to .env file:

RAILS_MAP_USERNAME=admin
RAILS_MAP_PASSWORD=your_secure_password

This automatically:

  • ✅ Creates config/initializers/rails_map.rb with authentication enabled
  • ✅ Mounts the engine at /rails-map
  • ✅ Adds /doc/api to .gitignore
  • ✅ Uses default credentials (admin/password) if ENV variables not set

Start your server and visit http://localhost:3000/rails-map - you'll be prompted to login!

Setup Without Authentication

If you don't want authentication (development only recommended):

rails g rails_map:install --skip-auth

This will:

  • ✅ Create the configuration file (auth disabled)
  • ✅ Mount the engine at /rails-map
  • ✅ Add /doc/api to .gitignore

Start your server and visit /rails-map - no login required!

Usage

Live Documentation (Recommended)

Mount the engine in your config/routes.rb:

mount RailsMap::Engine, at: '/rails-map'

Then visit http://localhost:3000/rails-map in your browser to see live documentation.

Static HTML Generation

Run the following rake task to generate static HTML documentation:

rails doc:generate

This will generate HTML documentation in doc/api/ directory.

Open Documentation in Browser

rails doc:open

Clean Generated Documentation

rails doc:clean

Configuration

Create an initializer config/initializers/rails_map.rb:

RailsMap.configure do |config|
  # Output directory for generated documentation
  config.output_dir = Rails.root.join('doc', 'api').to_s

  # Application name displayed in the documentation
  config.app_name = 'My Application'

  # Theme color (any valid CSS color)
  config.theme_color = '#3B82F6'

  # Include timestamp columns (created_at, updated_at) in model documentation
  config.include_timestamps = true

  # Include model validations in documentation
  config.include_validations = true

  # Include model scopes in documentation
  config.include_scopes = true

  # Authentication - Protect documentation with authentication
  # Uses environment variables: RAILS_MAP_USERNAME and RAILS_MAP_PASSWORD
  # Defaults to username: admin, password: password

  config.authenticate_with = proc {
    RailsMap::Auth.authenticate(self)
  }

  # Option 2: Devise
  # config.authenticate_with = proc {
  #   authenticate_user!
  # }

  # Option 3: Custom logic
  # config.authenticate_with = proc {
  #   redirect_to root_path unless current_user&.admin?
  # }
end

Features

  • 📱 Responsive Design - Works on desktop and mobile
  • 🎨 Customizable Theme - Change the primary color to match your brand
  • 🔗 Interlinked Pages - Easy navigation between related models and controllers
  • 🏷️ HTTP Method Badges - Color-coded badges for different HTTP methods
  • 📊 Statistics Dashboard - Quick overview of your application structure
  • 🔍 Association Type Badges - Visual distinction for different association types
  • 📝 API Parameter Detection - Automatically extracts and displays parameters for each route
    • Path parameters (:id, :user_id, etc.)
    • Query parameters for GET/DELETE requests
    • Request body parameters for POST/PUT/PATCH requests
    • Type inference (string, integer, boolean, datetime, etc.)
    • Required/optional indication
    • Parameter location (path, query, body)

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests.

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ArshdeepGrover/rails-map.

License

The gem is available as open source under the terms of the MIT License.