我想通过hirb
在rake任务中得到很好的打印效果。但我无法弄清楚如何设置hirb
来打印ActiveRecord
结果。
task :t2 => :environment do
require 'hirb'
Hirb.enable
result = Task.select('project_id, COUNT(*) AS counter').group('project_id').order('counter DESC')
puts Hirb::Helpers::Table.render(result)
Hirb.disable
end
我遇到错误“表必须是哈希数组或数组数组”
答案 0 :(得分:3)
puts Hirb::Helpers::AutoTable.render(active_record_object)