Stop rails console from printing out the object at the end of a loop

dsp_099 picture dsp_099 · Nov 8, 2012 · Viewed 26.2k times · Source

If I, say, loop through all the instances of a given model and output something from each, at the end, irb will still print the entire object.

If the object ends up taking hundreds of lines, it'll be a long way up before I see what I was actually looking for. Is there a way to disable this in the rails console?

Answer

aef picture aef · Nov 8, 2012

If you don't want to disable the echo in general you could also call multiple expressions in one command line. Only the last expression's output will be displayed.

big_result(input); 0