Skip to content

Instantly share code, notes, and snippets.

@brentd
Created January 29, 2010 20:01
Show Gist options
  • Save brentd/290058 to your computer and use it in GitHub Desktop.
Save brentd/290058 to your computer and use it in GitHub Desktop.
# Adds a view for MongoMapper documents when using Hirb.
begin
require 'hirb'
class Hirb::Views::MongoMapper_Document
def self.default_options
{:ancestor => true}
end
def self.render(rows, options={})
rows = Array(rows)
options[:fields] ||= begin
fields = rows.first.class.keys.keys.sort!
fields.map {|e| e.to_sym}
end
Hirb::Helpers::ObjectTable.render(rows, options)
end
end
Hirb::View.formatter.reload
rescue LoadError
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment