简体   繁体   中英

rails console - display active record results in a table

有没有办法在脚本/控制台环境中以表格格式显示Active Record结果?

Yep. There's a gem called hirb that does this very well.

Also check out http://tableprintgem.com . It's an efficient way to view a list of structured data, making it easy to scan and compare across large swaths of records (and for many people, it's a comfortable return to the SQL command line output of yesteryear :)

table_print ruby​​ gem  - 探索你的数据

The most powerful feature of table_print is the ability to see your data in the context of other objects it relates to. You can reference nested objects with the method chain required to reach them. This example is showing data from three different tables:

  • name from the Author table (reached through author.name)
  • title from the Book table (reached through author.books.title)
  • caption from the Photo table (reached through author.books.photos.caption)

table_print ruby​​ gem  - 将数据上下文化

There's a short intro screencast at http://tableprintgem.com

(full disclosure: I wrote this gem)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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