Skip to content

Ruby 2.7.5, Rails 6.1.4.4, Administrate 0.16.0 undefined batch_action_name #12

@stepheneb

Description

@stepheneb

The controller method SitesController#export_batch_action is undefined when rendering app/views/admin/application/index.html.erb

Context: Ruby 2.7.5, Rails 6.1.4.4, Administrate 0.16.0

Comparing all changes between main and administrate_batch_actions branches:
https://github.com/stepheneb/wts-rails6/compare/main...administrate_batch_actions

ActionView::Template::Error (undefined local variable or method `export_batch_action' for #<ActionView::Base:0x0000000000b2c0>
Did you mean?  export_batch_action_admin_sites_url):
    34: 
    35:   <%=
    36:     administrate_batch_actions_button(
    37:       export_batch_action,
    38:       export_batch_action_admin_sites_path,
    39:       { class: '', confirm: '' }
    40:     )
  
app/views/admin/application/index.html.erb:37

In the interactive console under the view error and asking for tab completion on in-scope objects starting with export.

>> export 
export_batch_action_admin_sites_path export_batch_action_admin_sites_url

My controller with a method named: export_batch_action

module Admin
  class SitesController < Admin::ApplicationController
    def export_batch_action
      Site.find(params[:batch_action_ids]).each(&:export)
      redirect_to :admin_sites, notice: "Successfully exported #{params[:batch_action_ids].size} sites"
    end
  end
end

And model with a Site#export method

class Site < ApplicationRecord
  def export
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions