Rails Console Pro
Enhanced Rails console with powerful debugging tools and beautiful formatting.
Rails Console Pro transforms your Rails console into a powerful debugging environment with schema inspection, SQL analysis, association navigation, and beautiful colored output.
โจ Features
- ๐จ Beautiful Formatting - Colored, styled output for ActiveRecord objects, relations, and collections
- ๐ Schema Inspection - Inspect database schemas with columns, indexes, associations, validations, and scopes
- ๐ SQL Explain - Analyze query execution plans with performance recommendations
- ๐งญ Association Navigator - Interactive navigation through model associations
- ๐ Model Statistics - Record counts, growth rates, table sizes, and index usage
- ๐ฌ Adaptive Profiling - Profile blocks or relations with query, cache, and performance metrics
- ๐งต ActiveJob Insights - Inspect and manage queues across adapters (Sidekiq, SolidQueue, Test, Async) with filters and inline actions
- ๐ Object Diffing - Compare ActiveRecord objects and highlight differences
- ๐ Model Introspection - Deep dive into callbacks, enums, concerns, scopes, validations, and method sources
- โ๏ธ Query Comparison - Compare multiple query strategies side-by-side to find optimal approaches
- ๐ง Query Builder - Interactive DSL for building and analyzing ActiveRecord queries
- ๐พ Export Capabilities - Export to JSON, YAML, and HTML formats
- ๐ Smart Pagination - Automatic pagination for large collections
- ๐ Snippet Library - Capture, search, and reuse console snippets across sessions
๐ Installation
Add this line to your application's Gemfile:
gem 'rails_console_pro'And then execute:
$ bundle installOr install it yourself as:
$ gem install rails_console_pro๐ Usage
The gem automatically loads when you start your Rails console. No additional setup required!
Quick Examples
# Schema inspection
schema User
# SQL explain
explain User.where(active: true)
# Model statistics
stats User
# Association navigation
navigate User
# Object diffing
diff user1, user2
# Export
export schema(User) user_schema.json
# Profiling
profile('Load users') { User.active.includes(:posts).limit(10).to_a }
# Queue insights
jobs(limit: 10, queue: 'mailers')
jobs status=retry class=ReminderJob
jobs retry=abcdef123456
jobs details=abcdef123456
# Model introspection
introspect User
introspect User, :callbacks
introspect User, :enums
introspect User, :method_name # Find where method is defined
# Query comparison
compare do |c|
c.run("Eager loading") { User.includes(:posts).to_a }
c.run("N+1") { User.all.map(&:posts) }
end
# Query builder
query User do
where(active: true)
includes(:posts)
order(:created_at)
limit(10)
end.analyze # Shows SQL + explainSee QUICK_START.md for more examples and detailed documentation for each feature.
โ๏ธ Configuration
Configure Rails Console Pro in an initializer:
# config/initializers/rails_console_pro.rb
RailsConsolePro.configure do |config|
# Enable/disable features
config.enabled = true
config.schema_command_enabled = true
config.explain_command_enabled = true
config.stats_command_enabled = true
config.queue_command_enabled = true
config.compare_command_enabled = true
config.query_builder_command_enabled = true
# Color scheme
config.color_scheme = :dark # or :light
# Customize colors
config.set_color(:header, :bright_blue)
# Pagination
config.pagination_enabled = true
config.pagination_threshold = 10
config.pagination_page_size = 5
end๐ฏ Requirements
- Ruby >= 3.0.0
- Rails >= 6.0
- Pry >= 0.14.0 (recommended)
๐ Documentation
- Quick Start Guide - Get started in minutes
- Schema Inspection - Inspect database schemas
- SQL Explain - Analyze query performance
- Model Statistics - Get model statistics
- Association Navigation - Navigate model associations
- Model Introspection - Deep dive into callbacks, enums, concerns, and more
- Object Diffing - Compare objects
- Export - Export to JSON, YAML, HTML
- Snippets - Build a reusable console snippet library
- Formatting - Beautiful console output
- Adaptive Profiling - Measure queries, cache hits, and potential N+1 issues
- Queue Insights - Inspect jobs across ActiveJob adapters
- Query Builder & Comparator - Compare query strategies and build optimized queries
๐ค Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/harshumaretiya/rails_console_pro.
๐ License
The gem is available as open source under the terms of the MIT License.
๐ Acknowledgments
- Inspired by awesome_print, hirb, and other console enhancement gems
- Built with love for the Rails community