I find myself having to type (for example)
include PathHelper
every time I load the Rails Console.
Is there a way to configure the Rails console to automatically include certain modules?
I find myself having to type (for example)
include PathHelper
every time I load the Rails Console.
Is there a way to configure the Rails console to automatically include certain modules?
Just in case anyone still feel confused, the simplest way to do this is:
.irbrc
file(if you userails console
) or.pryrc
file(if you usepry
)For example, if you use the default rails console and need to
include PathHelper
, just put it in the file:The
PathHelper
will be included automatically when you dorails console
I would check out this question.
Basically, modify your
config/application.rb
file to include the paths to any modules you want to auto-load.If you are still looking for an answer, this is what I do, I created a file
~/.irbrc
in which you put all the code you want to be auto loaded in your rails console.This is the content of my file:
The syntax for configuring rails console has changed. I found this on RailsGuides:
http://guides.rubyonrails.org/configuring.html#rails-general-configuration