Auto enable in Rails Console

I have to enter (for example)

enable pathhelper

every time I load the Rails console.

Is there a way to configure the Rails console to automatically enable certain modules?

+1
source share
3 answers

If you are still looking for an answer, this is what I am doing. I created a ~/.irbrc file in which you put all the code you want to load into your rails console.

This is the contents of my file:

 require "awesome_print" include Rails.application.routes.url_helpers AwesomePrint.irb! def y(obj) puts obj.to_yaml end 
+1
source

The syntax for configuring the rails console has changed. I found this on RailsGuides:

http://guides.rubyonrails.org/configuring.html#rails-general-configuration

 console do # this block is called only when running console, # so we can safely require pry here require "pry" config.console = Pry end 
+2
source

I checked this question .

Basically, modify your config/application.rb file to include the paths to any modules you want to load.

0
source

Source: https://habr.com/ru/post/1242611/


All Articles