How to get nice formatting in the Rails console

前端 未结 12 1468
一生所求
一生所求 2020-12-12 10:50

I want to get something like this to look nice:

>> ProductColor.all
=> [#

        
12条回答
  •  感动是毒
    2020-12-12 11:17

    I had some troubles making it work so I'll add my two cents to awesome_print add this to your Gemfile, preferably in :development

    gem 'awesome_print', require: 'ap'

    then in

    rails console

    you can do

    > ap Model.all That's it. However you can also add

    require "awesome_print"
    AwesomePrint.irb!
    

    to your ~/.irbrc, this way awesome_print will be required anytime you open the console and you can simply do

    Model.all without the need of typing ap

提交回复
热议问题