Rendered Text
  • Work
  • Team
  • Community
  • 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. The meaning of pain with mature tools

    May 11, 2012. comments

  2. Parsing email fields

    May 02, 2012. comments

  3. Notes from Railsberry 2012 day 1

    April 27, 2012. comments

  4. Filtering emails on staging

    April 27, 2012. comments

  5. Static code analysis will do you good

    April 23, 2012. comments

Archives