Rails console 'y' helper returns NameError rather than yaml-formatting output

Viewed 5699

I'm trying to use y object in Rails 3.2.6/Ruby 1.9.3 console to get nicely formatted yaml output for an ActiveRecord object, but for some reason it isn't working for me. I've used it in the past, but somewhere along the way it broke. I get the following output when I try:

NameError: undefined local variable or method `yaml' for main:Object
2 Answers

For rails 4/ruby 2 you could use just

puts object.to_yaml
Related