Sha256: 9f23ffa97aeb2e6308f6de46116c1265b0dc39346eef89f83476b98d47d5c8e3
Contents?: true
Size: 632 Bytes
Versions: 3
Compression:
Stored size: 632 Bytes
Contents
class Hirb::Helpers::ActiveRecordTable < Hirb::Helpers::ObjectTable # Rows are Rails' ActiveRecord::Base objects. # Takes same options as Hirb::Helpers::Table.render except as noted below. # # Options: # :fields- Can be any attribute, column or not. If not given, this defaults to the database table's columns. def self.render(rows, options={}) rows = [rows] unless rows.is_a?(Array) options[:fields] ||= begin fields = rows.first.attribute_names fields.unshift(fields.delete('id')) if fields.include?('id') fields.map {|e| e.to_sym } end super(rows, options) end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
cldwalker-hirb-0.1.1 | lib/hirb/helpers/active_record_table.rb |
cldwalker-hirb-0.1.2 | lib/hirb/helpers/active_record_table.rb |
hirb-0.1.2 | lib/hirb/helpers/active_record_table.rb |