Lukas Z's Blog

Quick Tip: Suppress Output in Rails Console and Irb

Let’s say you have a collection with 10.000 records in your database and you want to put them all in a large array for some reason. With Rails, you can write something like this:

records = Thing.all

Now you can go get yourself a coffee, because the content of all your records will be output to the console window and it will do so for a while.

Here’s the quick tip: If you want to suppress the output, simply do something like this:

records = Thing.all; 0

Problem solved. Easy, but I didn’t think of it immediately..

P.S.: You can follow me on Twitter.

Comments

Webmentions