We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Jamis Buck - Repurposing the Rails CLI - Rails World 2024
Learn how to extend the Rails CLI for MongoDB support with Jamis Buck. Discover techniques for custom commands, templates & best practices while preserving core functionality.
-
Thor is Rails’ command line framework - a tool for building self-documenting CLI applications where each public method becomes a command
-
Rails CLI is opinionated and built specifically for SQL databases, making MongoDB integration challenging out of the box
-
Key MongoDB integration challenges:
- Rails dbconsole doesn’t work with MongoDB
- Users must manually skip ActiveRecord
- Multiple manual setup steps required
- No built-in MongoDB CLI options
-
Solutions for extending Rails CLI for MongoDB:
- Using Rails templates to automate setup
- Monkey patching the Rails CLI safely
- Creating custom namespaces for MongoDB commands
- Symlinking binrails to custom implementations
- Preserving existing Rails CLI functionality while adding MongoDB support
-
Best practices for extending Rails CLI:
- Test against multiple Rails versions
- Lock dependencies to ensure stability
- Use templates for repeatable configuration
- Maintain familiar Rails-like interfaces
- Avoid breaking existing functionality
-
The Rails template system is powerful but underutilized:
- Allows custom configuration
- Can automate dependency setup
- Supports custom generators
- Enables consistent application bootstrapping
-
Success metrics for CLI extensions:
- Reducing setup steps to one line
- Maintaining familiar Rails workflows
- Preserving existing Rails commands
- Providing seamless database integration
- Supporting enterprise features like encryption
-
MongoDB users deserve the same quality tooling experience as SQL database users, even if MongoDB isn’t Rails’ primary focus