简体   繁体   English

如何在不安装gem的情况下以漂亮的格式输出Ruby on Rails控制台数据库结果集?

[英]How do you output Ruby on Rails console database resultsets in a pretty format without installing a gem?

I am getting data returned from running a database query like User.first but because there are so many fields it is hard to read the information. 我正在从运行数据库查询(如User.first返回数据,但是由于字段太多,因此很难读取信息。 I tried using pp User.first but it didn't make anything easier to read. 我尝试使用pp User.first但它并没有使任何内容更易于阅读。 Is there something built-in to RoR where I don't have to install a gem that prettifies it? RoR是否有内置的东西,而我不必安装可以美化它的gem? Also, I don't want to write an each statement to break it down each time if possible. 另外,如果可能的话,我不想每次编写每个语句来分解它。

If you don't like pp's output, I'm not sure what other options you have. 如果您不喜欢pp的输出,则不确定您还有其他选择。 If you can get over not wanting a gem, Hirb does this nicely... 如果您不想要一颗宝石就可以克服困难,Hirb可以很好地做到这一点...

https://github.com/cldwalker/hirb https://github.com/cldwalker/hirb

Why you need read it? 为什么需要阅读? You have a model structure in chema file and view for show your data. 您在chema文件中有一个模型结构,并可以查看以显示数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM