Skip to content

Fix compatibility with Administrate v1.0.0#57

Merged
andreibondarev merged 2 commits intoSourceLabsLLC:mainfrom
rdunlop:fix_compatibility_with_administrate_1_0_0
Feb 7, 2026
Merged

Fix compatibility with Administrate v1.0.0#57
andreibondarev merged 2 commits intoSourceLabsLLC:mainfrom
rdunlop:fix_compatibility_with_administrate_1_0_0

Conversation

@rdunlop
Copy link
Contributor

@rdunlop rdunlop commented Dec 31, 2025

They removed deprecated APIs.
The deprecation recommends these changes as recommended updates.

This appears to also address concerns listed here

Without this fix, I was getting:

ActionView::Template::Error (undefined method `show_action?'

They removed deprecated APIs thoughtbot/administrate#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 SourceLabsLLC#48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the gem’s Administrate index header partial and README examples to avoid using deprecated/removed Administrate action-check APIs, aiming to restore compatibility with Administrate v1.0.0.

Changes:

  • Updated the Export button visibility condition in app/views/admin/application/_index_header.html.erb.
  • Updated README snippets to use the new action-check predicates.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
app/views/admin/application/_index_header.html.erb Changes the condition used to decide whether to render the Export button.
README.md Updates documentation snippets showing how to add Export/New links manually.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

class: 'button',
target: '_blank'
) if valid_action?(:export) && show_action?(:export, resource_name) %>
) if existing_action?(resource_class, :export) && authorized_action?(resource_name, :export) %>
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The export button visibility check was changed to existing_action? + authorized_action?, but this partial already relies on accessible_action? for the New button (line 26). Given the PR goal (replace removed show_action?/valid_action?), using accessible_action? here as well would be more consistent and avoids introducing new dependencies (resource_class, existing_action?, authorized_action?) that may not exist across the supported Administrate versions.

Suggested change
) if existing_action?(resource_class, :export) && authorized_action?(resource_name, :export) %>
) if accessible_action?(resource_name, :export) %>

Copilot uses AI. Check for mistakes.

```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)
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README: the manual Export link now uses existing_action?(resource_class, :export) but the shipped _index_header partial also checks authorization. To avoid showing an Export button to users who aren’t allowed to export, align the README snippet with the view’s authorization check (or document why the authorization check is intentionally omitted).

Copilot uses AI. Check for mistakes.
[: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) %>
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README example now uses existing_action?/authorized_action? for the New button condition, but the gem’s bundled _index_header partial uses accessible_action? for New. This inconsistency can confuse users copying the example; update the README to use the same predicate(s) as the default partial (and ideally mirror the Administrate-recommended API for action visibility).

Copilot uses AI. Check for mistakes.
[: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) %>
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README export example later in the snippet checks only existing_action?(resource_class, :export) while the bundled partial checks both existence and authorization. Consider adding the authorization predicate here as well (or explicitly calling out that policies still need an export? method when using Pundit).

Copilot uses AI. Check for mistakes.
@andreibondarev andreibondarev merged commit 4469e04 into SourceLabsLLC:main Feb 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants