From ad1540cf0288c2bf52f3d959f38fb93fbb95f3aa Mon Sep 17 00:00:00 2001 From: Robin Dunlop Date: Tue, 30 Dec 2025 19:45:32 -0600 Subject: [PATCH] Fix compatibility with Administrate v1.0.0 They removed deprecated APIs https://github.com/thoughtbot/administrate/pull/2832. The deprecation recommends these changes as recommended updates. https://github.com/thoughtbot/administrate/pull/1941/changes This appears to also address concerns listed here https://github.com/SourceLabsLLC/administrate_exportable/issues/48 --- README.md | 6 +++--- app/views/admin/application/_index_header.html.erb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dea0841..8132cd3 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ ATTRIBUTE_TYPES = { By default the gem adds the Export button to the partial `views/admin/application/_index_header.html.erb`. But if you have your own Administrate `index` views or override that partial in your application you can add the link manually: ```ruby -link_to('Export', [:export, namespace.to_sym, page.resource_name.to_s.pluralize.to_sym, sanitized_order_params(page, :id).to_h.merge(format: :csv)], class: 'button') if valid_action?(:export) +link_to('Export', [:export, namespace.to_sym, page.resource_name.to_s.pluralize.to_sym, sanitized_order_params(page, :id).to_h.merge(format: :csv)], class: 'button') if existing_action?(resource_class, :export) ``` Example: @@ -78,13 +78,13 @@ Example: ), [:new, namespace.to_sym, page.resource_path.to_sym], class: "button", - ) if valid_action?(:new) && show_action?(:new, new_resource) %> + ) if existing_action?(resource_class, :new) && authorized_action?(new_resource, :new) %> <%= link_to( 'Export', [:export, namespace.to_sym, page.resource_name.to_s.pluralize.to_sym, sanitized_order_params(page, :id).to_h.merge(format: :csv)], class: 'button' - ) if valid_action?(:export) %> + ) if existing_action?(resource_class, :export) %> .... ``` diff --git a/app/views/admin/application/_index_header.html.erb b/app/views/admin/application/_index_header.html.erb index 1dfb610..3c334e1 100644 --- a/app/views/admin/application/_index_header.html.erb +++ b/app/views/admin/application/_index_header.html.erb @@ -30,6 +30,6 @@ [:export, namespace, page.resource_name.to_s.pluralize.to_sym, sanitized_order_params(page, :id).to_h.merge(format: :csv)], class: 'button', target: '_blank' - ) if valid_action?(:export) && show_action?(:export, resource_name) %> + ) if existing_action?(resource_class, :export) && authorized_action?(resource_name, :export) %>