Sha256: 449375ee4ec692b8b76d4aa56c625941ac85a23fae4c5c98cb60a85082a42036

Contents?: true

Size: 559 Bytes

Versions: 29

Compression:

Stored size: 559 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

29 entries across 29 versions & 1 rubygems

Version Path
slash_admin-1.5.11 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5.10 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5.9 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5.8 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5.7 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5.6 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5.5 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5.4 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5.3 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5.2 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5.1 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.5 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.4.1 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.4 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.3.5 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.3.4 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.3.3 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.3.2 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.3.1 app/controllers/slash_admin/batch_actions_controller.rb
slash_admin-1.3.0 app/controllers/slash_admin/batch_actions_controller.rb