Class: SlashAdmin::BatchActionsController

Inherits:
BaseController show all
Defined in:
app/controllers/slash_admin/batch_actions_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability

Instance Method Details

#deleteObject



5
6
7
8
# File 'app/controllers/slash_admin/batch_actions_controller.rb', line 5

def delete
  authorize! :destroy, model
  model.where(id: params[:ids]).delete_all
end

#modelObject

Raises:

  • (Exception)


10
11
12
13
14
15
16
# File 'app/controllers/slash_admin/batch_actions_controller.rb', line 10

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