Rails Console Pro

Gem Version Build Status

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 install

Or 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 + explain

See 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

🤝 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