SlashConsole
A Rails engine that provides a web-based console interface at /rails/console, allowing easy access to a Rails console in both development and production environments.
⚠️ Security Warning: This gem provides direct access to the rails console. Anyone who accesses it can run arbitrary code on the server: stealing/deleting all your data, planting bugs, sending scam emails, mining cryptocurrency, etc. So, be careful.
- Only use this gem in applications where the security trade-offs are acceptable. Basically, only for toy apps/proofs-of-concept/portfolio projects that contain only sample data. Never use this gem when real user data is at risk.
- For serious apps, SSH into the server and run
rails consoleat the command-line. This may require upgrading your hosting from free to paid, but you should be doing that anyway if you have real users. - Make up a strong, unique
ADMIN_PASSWORDfor each app.
Installation
Add this line to your application's Gemfile:
gem "slash_console"And then:
bundle installThat's it! Navigate to /rails/console in your browser.
Usage
Development
In development, no authentication is required. Simply visit /rails/console.
Production
For production use, authentication is required. Set these environment variables:
ADMIN_USERNAME="choose_your_own_username"
ADMIN_PASSWORD="choose_your_own_strong_password"Without these environment variables, you'll see an error message explaining what needs to be configured.
How It Works
SlashConsole is a lightweight wrapper around the excellent web-console gem. It:
- Provides a dedicated route for console access (instead of only on error pages).
- Renders a full-page console interface.
- Uses basic authentication when in production.
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests.
To install this gem onto your local machine, run bundle exec rake install.
Running Tests
bundle exec rake testLinting
This project uses Standard for Ruby style:
bundle exec standardrbContributing
Bug reports and pull requests are welcome on GitHub at https://github.com/firstdraft/slash_console.
Development Setup
- Fork the repository
- Create your feature branch (
git checkout -b my-new-feature) - Make your changes
- Run tests and linting
- Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
License
The gem is available as open source under the terms of the MIT License.
Acknowledgments
This gem is built on top of the web-console gem. Many thanks to the Rails team and web-console contributors for their excellent work.