Speed up pasting text into Rails console

Recently we had to copy and paste large amounts of text into a ruby console and we found a pretty quick way to do it

Sometimes you just need to copy and paste a load of text into a Rails console!

You would generally start up a new console rails console and start typing. You may have noticed that in newer versions of Ruby if you paste text it seems to input it quite slowly, one character at a time.

Rails uses IRB to manage the commands you enter and how the output is formatted. In recent years IRB has become an excellent tool, with lots of great features that we all take for granted, a simple one being syntax highlighting.

One of the tools that makes IRB so excellent is called multiline it allows for, you guessed it! multi line editing. This is super powerful. But it is also relatively expensive, especially when all you need to do is paste some text and let it run.

If all you need your IRB session to do is let you run a quick command (even if that command is long) then you can start a rails console without it.

To do that you run this command rails console -- --nomultiline. This will tell IRB to run without using multiline.

If you want to run IRB directly, you can disable multiline support with irb --nomultiline.

I was running the commands on a Rails application hosted on Heroku, in order to get no multiline support there I ran heroku run "rails console -- --nomultiline" --app my_awesome_rails_app.

If you’re wondering what the -- is between rails console and --nomultiline (I was). It means this is the end of the flags we’re passing to the original command (in this case rails), this means Rails must pass any additional flags right to IRB as an option.

Recent posts View all


The best way to test model scopes in Rails

Learn about Rails scopes and how to best test them with both Rspec and Minitest


Finding out what called a Ruby method

A quick way to understand what is calling your code using the caller method