Search code examples
ruby-on-railsrubyirb

How to run some default commands after firing the Rails console?


I need to run a few commands whenever I start my Rails console, like setting up the logger, or to set the time to my time zone.

Right now I'm copying and pasting these commands after Rails is started. Can I write a script to make these commands run automatically after IRB is started?


Solution

  • Rails' console is IRB. IRB supports an .irbrc file, which contains initialization information and settings.

    Read "https://stackoverflow.com/questions/123494/whats-your-favourite-irb-trick" and "My .irbrc for console/irb" for ideas.