Using hirb in rake task

130 views Asked by At

I would like to get nice printing by hirb in rake task. But I can't figure out how to setup hirb to print the ActiveRecord results.

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

I've got error "Table must be an array of hashes or array of arrays"

1

There are 1 answers

0
megas On BEST ANSWER
puts Hirb::Helpers::AutoTable.render(active_record_object)