RubyFlow : The Ruby Community Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  
 

Stop Rails Console from barfing a ton of data

When you use Rails' console for stuff like this:

people.each { |person| puts person.name }

You'll notice that first you get the names of people like you wanted, but then console barfs out the array of everything you are iterating through, in this case all of the people. Make it stop.

Comments

I've also been known to use ';0'. E.g.:

people.each { |person| puts person.name };0Brad - September 21, 2010 13:43
Please stop spamming rubyflow with nonsense like this.Anon - September 21, 2010 15:38
I have always done people.each { |person| puts person.name }; nil

This is great on heroku console as well.Knodi - September 21, 2010 15:43
http://www.youtube.com/watch?v=-f_DPrSEOEomadsheep - September 21, 2010 22:44

puts people.map(&:name)

is a better shortcut.PaulMcMahon - September 22, 2010 04:14
Really? There is a blog post on this? You people need to learn ruby and it's tools before acting like experts. You look foolish!AnonymousCritic - September 22, 2010 04:19

Post a Comment

Comment abilities for non registered users are currently deactivated, pending time to add a proper CAPTCHA to solve the escalating spam problem. Sorry!