Forum: Ruby on Rails Exporting ActiveRecords as yaml

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Giant C. (Guest)
on 2007-02-02 13:48

I have a number of .yml fixtures containing data that is loaded into my
db as a migration. Some of this data needs to be cleaned up, so I am
using the admin part of my rail app to do this editing.

I am now hoping to export the edited data back into yaml, so that I can
update my fixture data and drop and recreate the db as I need.

When I do something like:


I get output like:

 - !ruby/object:Colour
     name: Black
     id: "1"
 - !ruby/object:Colour
      name: Blue
      id: "2"

I am hoping to formal the yaml in the same way as the fixtures:

  id: 1
  name: 'Black'
  id: 2
  name: 'Blue'

Is this possible or do I have to format the output myself?

Christos Z. (Guest)
on 2007-02-03 20:36
(Received via mailing list)
Check this plugin out:

Careful when you use it; it overwrites your text fixtures.

You might want to just use part of the plugin's code to only do the
to yaml bit instead. Have a look here:

This topic is locked and can not be replied to.