How to use to_yaml method in Rails, and remove '---' -


i'm trying generate hash in yaml format, default, method adds --- in front of object.

> h = {key1: 'v1', key2: 'v2'} => {:key1=>"v1", :key2=>"v2"} > h.deep_stringify_keys.to_yaml => "---\n:key1: v1\n:key2: v2\n" 

brute force, it'll trick:

h.deep_stringify_keys.to_yaml[3..-1] 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -