Class: Dunlop::TargetFilesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dunlop/target_files_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#store_or_reset_params_q

Instance Method Details

#destroyObject



22
23
24
25
26
# File 'app/controllers/dunlop/target_files_controller.rb', line 22

def destroy
  authorize! :destroy, @target_file
  @target_file.destroy
  redirect_to dunlop.target_files_path, notice: t('action.destroy.successfull', model: @target_file.class.model_name.human)
end

#downloadObject



16
17
18
19
20
# File 'app/controllers/dunlop/target_files_controller.rb', line 16

def download
  authorize! :download, @target_file
  Dunlop::TargetFileDownload.create user: current_user, target_file: @target_file
  send_file @target_file.original_file.current_path
end

#indexObject



5
6
7
8
9
10
# File 'app/controllers/dunlop/target_files_controller.rb', line 5

def index
  authorize! :index, TargetFile
  @q = TargetFile.where(sti_type: TargetFile.classes.select{|cls| can? :read, cls}.map(&:name)).search(params[:q])
  @q.sorts = "created_at desc" if @q.sorts.empty?
  @target_files = @q.result.page(params[:page]).per(100)
end

#showObject



12
13
14
# File 'app/controllers/dunlop/target_files_controller.rb', line 12

def show
  authorize! :read, @target_file
end