Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
for generating Rails test fixture
require 'yaml'
def active_record_2_yaml(active_record)
hash = Array.wrap(active_record).as_json.reduce({}) {|memo, item|
memo["id_#{item['id']}"] = item
memo
}
hash.to_yaml
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment