Class: Users::ImagesController

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

Instance Attribute Summary

Attributes included from Authentication

#current_user

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
# File 'app/controllers/users/images_controller.rb', line 9

def create
  # Add validation to limit the file upload
  current_user.images.attach(params[:file])

  ok
rescue ActiveSupport::MessageVerifier::InvalidSignature
  bad_request
end

#destroyObject



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

def destroy
  image = current_user.images.find(params[:id])
  image.purge_later

  ok
end

#indexObject



3
4
5
6
7
# File 'app/controllers/users/images_controller.rb', line 3

def index
  @images = current_user.images_blobs

  ok(images: @images)
end