Class: SpotlightSearch::ExportJobsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Concerns::Exportable
Defined in:
app/controllers/spotlight_search/export_jobs_controller.rb

Instance Method Summary collapse

Instance Method Details

#export_jobObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/spotlight_search/export_jobs_controller.rb', line 5

def export_job
  begin
    klass = params[:klass].constantize
    if klass.validate_exportable_columns(params[:columns])
      ExportJob.perform_later(params[:email], klass, params[:columns], params[:filters])
      flash[:success] = 'Successfully queued for export'
    else
      flash[:error] = 'Invalid columns found'
    end
  rescue
    flash[:error] = 'No records to import'
  ensure
    redirect_back fallback_location: root_path
  end
end