lib/active_admin/resource/attributes.rb in activeadmin-4.0.0.beta8 vs lib/active_admin/resource/attributes.rb in activeadmin-4.0.0.beta9

- old
+ new

@@ -35,10 +35,17 @@ def sti_col?(c) c.name == resource_class.inheritance_column end def counter_cache_col?(c) - c.name.end_with?("_count") + # This helper is called inside a loop. Let's memoize the result. + @counter_cache_columns ||= begin + resource_class.reflect_on_all_associations(:has_many) + .select(&:has_cached_counter?) + .map(&:counter_cache_column) + end + + @counter_cache_columns.include?(c.name) end def filtered_col?(c) ActiveAdmin.application.filter_attributes.include?(c.name.to_sym) end