Created
September 3, 2009 06:44
-
-
Save cldwalker/180160 to your computer and use it in GitHub Desktop.
Example of customizing hirb helper for active record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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