I want to write out a series of records to a text file so that I can
quickly edit them and then upload then again into the database. To do
this I am using YAML and some code that looks like this:
item = Item.find 153
File.open( ‘item.yaml’, ‘w’ ) do |out|
YAML.dump( item, out )
This dumps out all the field names and values which are stored in the
attributes hash. The output looks something like this:
… many more fields
However I don’t want all these fields. How can I limit the YAML output
to just include the fields that I want?
I know that I can override to_yaml_properties to specify the fields that
i want from a class. But that really only lets me choose whether I want
to export @attributes or not. I think that I could override
to_yaml_properties of @attributes. Something like this
But I’m not too sure what I should write there?
Or maybe I should be overriding def [email protected]_yaml ?
Does anyone have any ideas?
image_alignment: '' display_format: Vertical minimum_number_responses: item_sub_text: '' page_number: 5 row_text_width: email_address_yn: N survey_id: 153 other_yn: N random_answer_order_yn: N database_dsn: '' image_width: '' other_display_type: subitem_count: answer_total: item_text: "<span style=\"font-weight:bold\">When a good has
positive network externalities,
this means that when using the product:"
other_text: “Other, please specify”