A Rails gem that tracks and visualizes database operations in your application. Built for developers who need to understand complex data flows and debug database interactions.
- Database Operation Tracking - Capture SQL operations (INSERT, UPDATE, DELETE)
- Targeted Monitoring - Track specific code blocks or entire HTTP requests
- Interactive Dashboard - Clean web interface for exploring captured data
- Relationship Diagrams - Visualize database relationships and model associations
- Simple Setup - File-based storage with zero additional database requirements
- Development Ready - Designed specifically for development environments
View more screenshots in here →
Add to your Gemfile:
gem 'dbwatcher', group: :development
Install the gem:
bundle install
The dashboard automatically becomes available at /dbwatcher
in your Rails application.
Monitor specific operations:
Dbwatcher.track(name: "User Registration") do
user = User.create!(name: "John", email: "[email protected]")
user.create_profile!(bio: "Developer")
user.posts.create!(title: "Hello World")
end
Add ?dbwatch=true
to any URL:
GET /users/123?dbwatch=true
POST /api/users?dbwatch=true
Visit /dbwatcher
in your browser to explore tracked operations.
Optional configuration in config/initializers/dbwatcher.rb
:
Dbwatcher.configure do |config|
config.storage_path = Rails.root.join('tmp', 'dbwatcher')
config.enabled = Rails.env.development?
config.max_sessions = 100
config.auto_clean_after_days = 7
end
Add context to your tracking:
Dbwatcher.track(
name: "Order Processing",
metadata: { user_id: current_user.id, order_type: "premium" }
) do
# Database operations here
end
Use in your test suite:
it "creates user with associations" do
Dbwatcher.track(name: "User Creation Test") do
user = create(:user)
expect(user.profile).to be_present
end
end
bundle exec rake test # All tests
bundle exec rake unit # Unit tests only
bundle exec rake acceptance # Feature tests only
cd spec/dummy
bundle exec rails server -p 3001
open http://localhost:3001/dbwatcher
bundle exec rubocop # Linting
bundle exec brakeman # Security analysis
- Fork the repository
- Create a feature branch:
git checkout -b my-feature
- Make changes and add tests
- Run tests:
bundle exec rake test
- Run linter:
bundle exec rubocop
- Commit changes:
git commit -am 'Add feature'
- Push branch:
git push origin my-feature
- Open a Pull Request
If you see undefined method 'dbwatcher_sessions_path'
:
- Restart your Rails server after installing
- Verify Rails 6.0+ compatibility
- Check engine mounting in routes if needed
- Designed for development environments only
- Disable in production:
config.enabled = false
- Use targeted tracking for performance-critical code
- Enable auto-cleanup to prevent storage bloat
Released under the MIT License.