I'd like to set an IRB configuration across an application (all environments, including production), so I don't have to run it every time I use the Ruby on 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 Ruby on Rails console
IRB.conf[:USE_PAGER]
# => true
confirming that it hasn't set (or was set but was overridden).
.irbrc
in the application itself. When I attempted the answer, my *bin directory doesn't have a file called console (just bundle, dev, rails, rake, or 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 documentation says "the first file found", all the files found will be loaded:
IRB searches for a configuration file in the following order:
$IRBRC
$XDG_CONFIG_HOME/irb/irbrc
$HOME/.irbrc
$HOME/.config/irb/irbrc
.irbrc
in the current directoryirb.rc
in the current directory_irbrc
in the current directory$irbrc
in the current directory
https://ruby.github.io/irb/Configurations_md.html#label-Configuration+File+Path+Resolution