RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

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 };0

Please stop spamming rubyflow with nonsense like this.

I have always done people.each { person puts person.name }; nil

This is great on heroku console as well.

puts people.map(&:name) is a better shortcut.

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!

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in