Marko Anastasov wrote this on February 18, 2009
Getting fixture data quickly from the database with console and #to_yaml
Whenever I’m working on a project, I keep a Rails console for it open, usually to quickly inspect our models and database. It can be very handy when you need to prepare some fixture data as well. Just grab a model instance and call
File.open("data.fix", "w") { |f| f.write foo.to_yaml }
to dump it to a file.