Class: Admin::DocumentsController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/c/admin/documents_controller.rb

Instance Method Summary collapse

Instance Method Details

#bulk_uploadObject



31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/c/admin/documents_controller.rb', line 31

def bulk_upload
  count = 0

  params[:documents][:attachments].each do |attachment|
    document = C::Document.new(name: attachment[:attachment].original_filename, document: attachment[:attachment])
    count += 1 if document.save
  end

  redirect_to documents_path, notice: "#{count} document(s) uploaded"
end

#createObject



10
11
12
13
14
15
16
# File 'app/controllers/c/admin/documents_controller.rb', line 10

def create
  if @document.save
    redirect_to documents_path, notice: 'Document created'
  else
    render :new
  end
end

#destroyObject



26
27
28
29
# File 'app/controllers/c/admin/documents_controller.rb', line 26

def destroy
  @document.delete
  redirect_to documents_path, notice: 'Document deleted'
end

#indexObject



8
# File 'app/controllers/c/admin/documents_controller.rb', line 8

def index; end

#updateObject



18
19
20
21
22
23
24
# File 'app/controllers/c/admin/documents_controller.rb', line 18

def update
  if @document.update(document_params)
    redirect_to documents_path, notice: 'Document updated'
  else
    render :edit
  end
end