How to start the rail console with the output turned off?

Sometimes I have a reason to want to run the rail console as a replacement for irb rather than pry (as surprising as pry is). By default, it will be installed because pry has a Gemfile. Howe is it now?

I think when running the rails console used to be the -irb option, but it seems to be gone now. I get an obsolete error message when I try it.

More details

If I just run the โ€œrails consoleโ€, it makes me peek.

If I run "rails console -irb = irb":

 $ rails c -irb=irb --irb option is no longer supported. Invoke `/your/choice/of/ruby script/rails console` instead 

Relevant lines from my gemfile:

 gem 'rails', '3.2.18' gem 'pry-rails' gem 'pry-plus' 
+8
ruby-on-rails pry
source share
4 answers

Running pry when calling rails console or rails c configured using the pry-rails gem. If you look at pry-rails problems there is one that describes the solution.

Define the DISABLE_PRY_RAILS environment variable as 1 .

So you can call the rails console without pry with

 DISABLE_PRY_RAILS=1 rails c 
+14
source share

Works in Rails 4: In your application.rb , inside your Application class, release this puppy.

 # Use the IRB console instead of the Pry one console do require 'irb' config.console = IRB end 

I could no longer accept the Pry console. He constantly placed the cursor in strange places at unpredictable times. I canโ€™t even describe it, but if you know what I'm talking about and know a solution, please let me know.

+5
source share

In the interest of anyone who runs into the same problem, this is my (crappy) workaround.

I wrapped gems in a gemfile with this:

 ... unless ENV['NOPRY'] gem 'pry-rails' gem 'pry-plus' end ... 

Then run this from unix terminal:

 NOPRY=true bundle install NOPRY=true rails console 

Not really, but it does its job ...

+1
source share

Inspired by the answers above, I added the following class definition to application.rb so that Pry would switch from the console:

 console do if ENV['IRB'] require 'irb' config.console = IRB end end 

You can then run rails c to get the Pry console, and IRB=true rails c to get the IRB console. This is easy to change if you want to invert. Works in Rails 4 and 5.

0
source share

All Articles