Rails console history for Heroku, Docker, and more
Designed for platforms with ephemeral filesystems
Add this line to your application’s Gemfile:
gem "archer-rails"
And run:
rails generate archer:install
rails db:migrate
Lastly, update your Gemfile to only include it in environments where you need it:
gem "archer-rails", group: [:production]
Ruby stores console history in a file specified by:
IRB.conf[:HISTORY_FILE]
This file gets lost on ephemeral filesystems. Instead, we store its contents in the database.
Each user can keep their own history. The user determined by ENV["USER"]
by default. You can specify a user when starting the console with:
USER=andrew rails console
Confirm it worked with:
Archer.user
Disable saving history for the current session with:
Archer.save_session = false
You should do this when running sensitive commands.
Clear history for current user with:
Archer.clear
Change the number of commands to remember
Archer.limit = 200 # default
Change how the user is determined
Archer.user = ENV["USER"] # default
For user-specific history, the command should follow this format:
heroku run USER=andrew rails console
Set up an alias to save yourself some typing
alias hc="heroku run USER=andrew rails console"
There’s no way to specify a user at the moment.
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/archer.git
cd archer
bundle install
bundle exec rake test