-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Issue
Using administrate_exportable with administrate v0.18.0 will cause a deprecation warning to get logged in test and development. They look like this:
DEPRECATION WARNING: The method `valid_action?` is deprecated. Please use `accessible_action?`
instead, or see the documentation for other options. (called from valid_action?
at <GEM_PATH>/administrate-0.18.0/app/controllers/administrate/application_controller.rb:125)
Apparently the practice of calling valid_action? and show_action? was replaced with a single call to a new method, accessible_action? in this PR: thoughtbot/administrate#1941
As far as I can tell, that PR is part of administrate v0.18.0, and unfortunately accessible_action? doesn't exist in versions before v0.18.0.
I'm guessing that making the deprecation warning go away at the cost of breaking compatibility with older versions isn't worth it, and neither is making the behavior conditional on e.g. Gem.loaded_specs["administrate"].version ... but I thought I'd make this issue for documentation value at least.
Workaround
The change, were it made, would result in the export button's link_to in app/views/admin/application/_index_header.html.erb becoming:
<%= link_to(
'Export',
[: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 accessible_action?(page.resource_name, :export) %>Folks using the latest administrate who wish to avoid the warning can simply copy administrate_exportable's version of _index_header.html.erb into their project, and update the export button's link_to to the above. (Generating views in administrate didn't spit out the file when I tried it.)
Finally, it might be of some use to update the readme to provide both versions -- @andreibondarev I'm happy to make a PR with whatever change is desired, if a change is desired at all.