Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
How replicate rails console output style in runner script?

When running User.first in the rails console I will get a beautiful output, something like:

beautiful output in rails console

I assume this is taken care of by pry. How can I get the same output styling when using the runner? Consider a file tinker.rb

u = User.first
puts u

and running it like: rails r './tinker.rb. While it will output something, it is not as polished as in the console:

#<User:0x00007fc6518acec8>

How can I make it exactly the same?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This formatting is a result of PrettyPrint module - PP:

u = User.first
pp u #=> Which is basically a shortcut for: PP.pp(u)

Note however, that by default this will not generate a colourful output. Pry additionally process the formatted string through another gem - coderay, which is responsible for ruby syntax highlighting. If you want to print in colour, then:

u = User.first
Pry::ColorPrinter.pp(u)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!