diff --git a/app/controllers/administrate/application_controller.rb b/app/controllers/administrate/application_controller.rb index 849c1b70e3..ae2ea23bdd 100644 --- a/app/controllers/administrate/application_controller.rb +++ b/app/controllers/administrate/application_controller.rb @@ -109,15 +109,7 @@ def find_resource(param) end def resource_includes - association_classes = [ - Administrate::Field::HasMany, Administrate::Field::HasOne, - Administrate::Field::BelongsTo - ] - - dashboard.class::ATTRIBUTE_TYPES.map do |key, value| - key if association_classes.include?(value) || - association_classes.include?(value.try :deferred_class) - end.compact + dashboard.association_includes end def resource_params diff --git a/lib/administrate/base_dashboard.rb b/lib/administrate/base_dashboard.rb index 04d140dd4e..72ea20f220 100644 --- a/lib/administrate/base_dashboard.rb +++ b/lib/administrate/base_dashboard.rb @@ -52,6 +52,17 @@ def display_resource(resource) "#{resource.class} ##{resource.id}" end + def association_includes + association_classes = [Field::HasMany, Field::HasOne, Field::BelongsTo] + + collection_attributes.map do |key| + field = self.class::ATTRIBUTE_TYPES[key] + + next key if association_classes.include?(field) + key if association_classes.include?(field.try :deferred_class) + end.compact + end + private def attribute_not_found_message(attr)