Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

300
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda