class ActiveAdmin::Views::AttributesTable

Attributes

resource[R]

Public Instance Methods

build(record, *attrs) click to toggle source
Calls superclass method
# File lib/active_admin/views/components/attributes_table.rb, line 9
def build(record, *attrs)
  @record = record
  super(:for => @record)
  @table = table
  rows(*attrs)
end
row(*args, &block) click to toggle source
# File lib/active_admin/views/components/attributes_table.rb, line 20
def row(*args, &block)
  title   = args[0]
  options = args.extract_options!
  options[:class] ||= :row
  @table << tr(options) do
    th do
      header_content_for(title)
    end
    td do
      content_for(block || title)
    end
  end
end
rows(*attrs) click to toggle source
# File lib/active_admin/views/components/attributes_table.rb, line 16
def rows(*attrs)
  attrs.each {|attr| row(attr) }
end

Protected Instance Methods

content_for(attr) click to toggle source
# File lib/active_admin/views/components/attributes_table.rb, line 52
def content_for(attr)
  previous = current_arbre_element.to_s
  value    = pretty_format find_attr_value attr
  value.blank? && previous == current_arbre_element.to_s ? empty_value : value
end
default_id_for_prefix() click to toggle source
# File lib/active_admin/views/components/attributes_table.rb, line 36
def default_id_for_prefix
  'attributes_table'
end
empty_value() click to toggle source
# File lib/active_admin/views/components/attributes_table.rb, line 48
def empty_value
  span I18n.t('active_admin.empty'), :class => "empty"
end
find_attr_value(attr) click to toggle source
# File lib/active_admin/views/components/attributes_table.rb, line 58
def find_attr_value(attr)
  if attr.is_a?(Proc)
    attr.call(@record)
  elsif attr.to_s[/\A(.+)_id\z/] && @record.respond_to?($1.to_sym)
    @record.send($1.to_sym)
  else
    @record.send(attr.to_sym)
  end
end
header_content_for(attr) click to toggle source
# File lib/active_admin/views/components/attributes_table.rb, line 40
def header_content_for(attr)
  if @record.class.respond_to?(:human_attribute_name)
    @record.class.human_attribute_name(attr, :default => attr.to_s.titleize)
  else
    attr.to_s.titleize
  end
end