Class: Raindrops::DownloadsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/raindrops/downloads_controller.rb

Overview

Controlleur de gestion des téléchargements

Instance Method Summary collapse

Instance Method Details

#createObject

Ajoute un téléchargement.


22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/raindrops/downloads_controller.rb', line 22

def create
  # @todo Retirer cette constante en dur
  @download.destination_path = "/home/nicolas/Bureau/#{SecureRandom.hex}.zip"
  if @download.valid?
    download = Raindrops::Download.new source_url: @download.source_url,
                                       destination_path: @download.destination_path
    download.save
    download.delay.start
  end

  render :index
end

#destroyObject

Efface un téléchargement


38
39
40
41
# File 'app/controllers/raindrops/downloads_controller.rb', line 38

def destroy
  @download.destroy!
  redirect_to action: :index, status: 303
end

#indexObject

Affiche la liste des téléchargements en cours, ainsi que le formulaire de téléchargement.


12
13
14
15
16
17
# File 'app/controllers/raindrops/downloads_controller.rb', line 12

def index
  respond_to do |format|
    format.html
    format.json
  end
end