Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

301
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda