Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable pager in rails console so entire result prints to console?

When running an ActiveRecord query in the rails console, I see as much of the result that fits on the screen, followed by a : and a flashing cursor indicating a pager is in use.

Is there a way (e.g. a setting I can tinker with) to disable this pager for the whole rails console session, so all content displayed is printed to the rails console in its entirety without use of a pager?

What I know so far

I tried running these in a fresh rails console session:

IRB.conf[:USE_MULTILINE] = false
IRB.conf[:PAGER] = false

if defined?(Rails::Console)
  Rails.application.console do
    IRB.conf[:USE_MULTILINE] = false
    IRB.conf[:PAGER] = false
  end
end

But when I run an ActiveRecord query and the result doesn't fit on screen it still invokes the pager just as before.

like image 979
stevec Avatar asked Oct 19 '25 14:10

stevec


1 Answers

Configuration is:

IRB.conf[:USE_PAGER] = false

Doesn't look like it's documented anywhere, but you can see available options:

>> IRB.conf
=> 
{:VERSION=>"irb 1.13.1 (2024-05-05)",
 :AP_NAME=>"irb",
 :IRB_NAME=>"irb",
 :IRB_LIB_PATH=>"/home/alex/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.13.1/lib/irb",
 :RC=>true,
 :LOAD_MODULES=>[],
 :IRB_RC=>nil,
 :USE_COLORIZE=>true,
 :USE_AUTOCOMPLETE=>false,
 :COMPLETOR=>:regexp,
 :INSPECT_MODE=>true,
 :USE_TRACER=>false,
 :USE_LOADER=>false,
 :IGNORE_SIGINT=>true,
 :IGNORE_EOF=>false,
 :USE_PAGER=>true,         # <=
...

That's all there is on :USE_PAGER: https://github.com/ruby/irb/pull/783

like image 69
Alex Avatar answered Oct 21 '25 05:10

Alex