Forum: Ruby on Rails Exporting ActiveRecords as yaml

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

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:

  Colour.find(:all).to_yaml

I get output like:

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

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

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


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

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

http://nubyonrails.com/articles/2005/12/27/dump-or...
reference-data

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:

http://topfunky.net/svn/plugins/ar_fixtures/lib/ar...

-christos
This topic is locked and can not be replied to.