Skip to content

Instantly share code, notes, and snippets.

@kokigit
Created May 17, 2018 06:11
Show Gist options
  • Save kokigit/f6ef515074fb47ff5fc2f94df36a04bf to your computer and use it in GitHub Desktop.
Save kokigit/f6ef515074fb47ff5fc2f94df36a04bf to your computer and use it in GitHub Desktop.
to print rails active record objects with indented json out put put this function on ~/.irbrc file. then it will be loaded with irb or rails console
def pp(obj)
puts JSON.pretty_generate({ "#{obj.class.name.underscore}" => obj }.as_json)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment