Class: LadyJosephine::ImagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/lady_josephine/images_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/lady_josephine/images_controller.rb', line 4

def create
  image = Image.from_params image_params

  if image && image.save
    response = {file: {url: image.file.url}, versions: sizes_hash(image.file)}
    render json: response.as_json, status: 200
  elsif image
    render json: image.file.errors,  status: 500
  else
    render json: { error: 'Could not save Image.'} ,  status: 500
  end
end