Skip to content

Instantly share code, notes, and snippets.

@sugumura sugumura/command.rb
Created Jul 19, 2018

What would you like to do?
Rails consoleでJSONを出力したいとき
# ファイルに書き出したい
>> f = + 'hoge.json', 'w')
>> f << JSON.pretty_generate(Post.all.as_json)
>> f.close
# 出力したい
>> puts JSON.pretty_generate(Post.all.as_json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.