Created
September 16, 2016 16:59
-
-
Save elegantcoder/125a411dec4e79c8e370c53083f6ffec to your computer and use it in GitHub Desktop.
for generating Rails test fixture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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