Skip to content

Instantly share code, notes, and snippets.

@cldwalker
Created September 3, 2009 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cldwalker/180160 to your computer and use it in GitHub Desktop.
Save cldwalker/180160 to your computer and use it in GitHub Desktop.
Example of customizing hirb helper for active record
# Customize description to include model class
class Hirb::Helpers::MyActiveRecordTable < Hirb::Helpers::AutoTable
def self.render(rows, options={})
@model_class = rows.is_a?(Array) ? rows[0].class : rows.class
super
end
def self.model_class; @model_class; end
def render_table_description
"#{self.class.model_class}: #{super}"
end
end
# Hirb.enable :output=>{ "ActiveRecord::Base"=>{:class=>:my_active_record_table, :ancestor=>true} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment