我想通过在 rake 任务中hirb
获得漂亮的打印。但是我不知道如何设置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
我收到错误"表必须是哈希数组或数组数组"
puts Hirb::Helpers::AutoTable.render(active_record_object)