I am trying to dump an ActveRecord tree structure (created using
acts_as_tree) with elements that also have associations.
I want to dump the YAML representation as text, edit it and then
reload it. The current state of my project means that this is the
most efficient way to get bulk changes working.
After spendign a day Googling I cannot see a way to dump a subset of
the ActiveRecord attributes.
updated_at: 2008-03-19 14:34:28
created_at: 2008-03-19 14:34:28
is what I get when I dump an instance to YAML.
But I don’t want the *id, created_at and updated_at fields, since
they’re irrelevant to my needs and will change when I reload this
I can see how to_yaml_properties works for simple objects and indeed
if I use that method to limit the instance variables I want to see
then I get:
props = self.attributes
But now this cannot be reloaded as an Expectation object because these
instance variables are now no longer in the attributes section as they
were in the previous dump
Other than running a post-dump textual deletion of these entries I am
I note that the to_xml methods allow this kind of feature but to_yaml
doesn’t seem to offer anything like this.