Rendered Text
  • Work
  • Team
  • 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. Smartly truncate long text and markup with jquery.truncator

    May 19, 2010. comments

  2. Using Flickr API with Ruby and r2flickr

    May 13, 2010. comments

  3. Hope for HTML5 history

    April 13, 2010. comments

  4. Rendering Textpattern

    March 15, 2010. comments

  5. Authentication methods in popular web APIs

    March 02, 2010. comments

Archives