I am displaying a table with ActiveAdmin using the "Index as Table" functionality:
index :pagination_total => false do
if Ability.new(current_user).can? :manage, :metric
selectable_column
end
column '' do |metric|
links = link_to(metric.icon, admin_metric_path(metric), :title => metric.comment)
links += link_to(metric.data_icon, admin_metric_path(metric)) unless metric.datum_ids.empty?
links
end
column 'Status', :success, sortable: :success do |metric|
metric.success == 1 ? status_tag('Success', :ok) : status_tag('FAILED', :error)
end
column 'When (UTC)', :createddttm
column 'What', :metric_name
column 'Area', :logarea
column 'Subarea', :subarea
column 'Value', :value
column 'Machine', :machine_name, sortable: 'machinename.machinename'
column 'Domain', :domain_name, sortable: 'domain.domainname'
column 'Product', :product_name, sortable: 'product.productname'
column 'Version', :product_version, sortable: 'product.productversion'
column 'Install Type', :install_type, sortable: 'product.productinstalltype'
column 'Lang', :language
column 'Duration', :duration
end
Given that the row data does not change, I would like to add row level caching of the rendered html with a long expiry time but I can't figure out how to hook into the row rendering code in Arbre.
I am currently caching the entire page for 60 seconds but that is not optimal. My cache store is Dalli / memcached.
UPDATE 2:
Try this with the
cashed_rows
method:UPDATE: This is a monkey patch. Create a new file in lib folder, then you can use the
rows
array.Now you can get the html string: YourActiveRecordModel.cached_rows if you build the index table at least once.
Old answer:
I would make a new table that contains the string representation of the contained objects. You can determine which record want to load (the original or the cached record):
https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#customizing-resource-retrieval