6

How can I make awesome_print be the default in the heroku console?

When I type Model.all in the console, I would like awesome_print to display the results without having to type ap Model.all.

webmagnets
  • 2,266
  • 3
  • 33
  • 60

3 Answers3

5

The following gem combination seems to accomplish it in Rails 4.

# for the pretty
gem 'pry'
gem 'pry-rails'
gem 'pry-doc'
gem 'pry-awesome_print'
gem "awesome_print"

You can also remove from your .pryrc the following lines and it will work anyway :

require 'awesome_print'
AwesomePrint.pry!

Happy printing!

Trip
  • 26,756
  • 46
  • 158
  • 277
  • 1
    This works beautifully in rails 5.1.6 and should be the accepted answer. – glaux Aug 09 '18 at 13:20
  • 1
    This is the only solution I've found that works for formatting devise models in IRB as well. Using rails 5.2.2 as well. thank you – Luke Popwell Dec 11 '18 at 21:15
2

Try installing pry, it has functionality like awesome print and more, and has instructions for installing into a rails application: http://pryrepl.org/

Will
  • 2,921
  • 16
  • 12
  • 1
    I was able to get pry installed, but it doesn't print with a nice layout like awesome print does. Is there a way to make it print like awesome print? – webmagnets Jan 15 '13 at 13:47
0

If you have awesome_print gem you simply just use AwesomePrint.irb! in the console and voila.. it will display the output as how you want.

N. Maina
  • 1
  • 1