Sha256: 6d8bd98ce62570c8666f3d5bc2ea70dc02d9d138417ca177596a01fff270bd43

Contents?: true

Size: 558 Bytes

Versions: 3

Compression:

Stored size: 558 Bytes

Contents

# frozen_string_literal: true
module SlashAdmin
  class BatchActionsController < SlashAdmin::BaseController
    def delete
      authorize! :destroy, model
      model.where(id: params[:ids]).delete_all
    end

    def model
      ActiveRecord::Base.connection.tables.map do |klass|
        testing_class = klass.capitalize.singularize.camelize
        return testing_class.constantize if testing_class == params[:model_class].capitalize.singularize.camelize
      end
      raise Exception.new("Can't find model #{params[:model_class]}")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slash_admin-1.0.1 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.0 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-0.1.0 app/controllers/slash_admin/batch_actions_controller.rb