Class: AttachmentsController

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

Instance Method Summary collapse

Instance Method Details

#destroyObject



18
19
20
21
22
23
# File 'app/controllers/attachments_controller.rb', line 18

def destroy
  @attachment = Attachment.find params[:id]
  @attachment.save_and_destroy(current_user)

  render json: {}
end

#showObject



4
5
6
7
8
9
10
11
# File 'app/controllers/attachments_controller.rb', line 4

def show
  attachment = Attachment.find params[:id]

  send_data attachment.file_data,
    type:         attachment.content_type,
    filename:     attachment.filename,
    disposition:  'inline'
end

#uploadObject



13
14
15
16
# File 'app/controllers/attachments_controller.rb', line 13

def upload
  @attachment = Attachment.find params[:id]
  @attachment.update(params[:file], current_user)
end