Pass a Block on Console Load
Have some Ruby code you want to run as the Rails console loads? Here's a technique.
In this example, I'm going to use a function from the hirb gem. Add the gem to your Gemfile and
Next, pass a block to
console in your application configuration.
# config/application.rb module MyApplication class Application < Rails::Application console do # Action(s) I want to run on console load... Hirb.enable end end end
The next time you start the Rails console,
Hirb.enable will run after load.