Rendered Text
  • Work
  • Team
  • Toolbox
  • Contact
  • Blog
Feed

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.

Comments powered by Disqus

Recent Entries

  1. Sucking less at writing Cucumber

    December 06, 2011. comments

  2. Agile and change

    November 29, 2011. comments

  3. Apprenticing at Rendered Text

    October 21, 2011. comments

  4. Making change

    October 18, 2011. comments

  5. How to solve the losing X11 connection problem with VirtualBox on Mac OS Lion

    October 17, 2011. comments

Archives