Is there a way to get "rails console" to load .irbrc? Or am I supposed to use something else?
2 Answers
rails console
by default loads ~/.irbrc
, so I don't really understand your question. It will, however, fail silently (and do not load it) if there are some errors in this file.
One example of such error is requiring gems not defined in the Gemfile (for Rails3 + Bundler) and not rescuing from LoadErrors (or expecting the require to "just work").
-
4I was just playing around with this and it turns out that if I add a .irbrc file to the root of a project, it won't work unless I also have a ~/.irbrc file. Jul 25, 2012 at 1:03
rails c
does not load any other .irbrc
but from the current user's home (~
).
See https://gist.github.com/railsbros-dirk/719848
You can tweak your rails application.rb
to load the root .irbrc
file if present.
-
4how can we change application.rb to load .irbrc for project's root folder? Jun 11, 2020 at 11:53
rails console
comes up with a prompt that sayspry(main)
, use.pryrc
instead..irbrc
in~/
. Once I put it there (or rather simlinked) it worked exactly as expected. Double check just so you do not look foolish like I did :-P