I'd like to set an IRB configuration across an app (all environments, including production) so I don't have to run it every time I use the rails console. The specific configuration isn't that important, but it's:
IRB.conf[:USE_PAGER] = false
I thought it would be as simple as:
# config/initializers/console.rb
Rails.application.console do
IRB.conf[:USE_PAGER] = false
end
but when I open the rails console
IRB.conf[:USE_PAGER]
# => true
confirming that it hasn't set (or was set but was overridden).
~/.irbrc
file but that wouldn't work across multiple machines (e.g. the configuration should be applied in production, not just locally)
.irbrc
in the app itself. When I attempted the answer, my bin
directory doesn't have a file called console
(just bundle
, dev
, rails
, rake
, setup
)You can add .irbrc
into your project. There are multiple locations that a configuration file can be loaded from, including the current directory, which can be your project. Although, the docs say "the first file found", all the files found will be loaded:
The path to the configuration file is the first found among:
- The value of variable
$IRBRC
, if defined.- The value of variable
$XDG_CONFIG_HOME/irb/irbrc
, if defined.- File
$HOME/.irbrc
, if it exists.- File
$HOME/.config/irb/irbrc
, if it exists.- File
.irbrc
in the current directory, if it exists.- File
irb.rc
in the current directory, if it exists.- File
_irbrc
in the current directory, if it exists.- File
$irbrc
in the current directory, if it exists.
https://docs.ruby-lang.org/en/master/IRB.html#module-IRB-label-Configuration+File