Module: Simplec::EmbeddedImageActions::InstanceMethods

Defined in:
lib/simplec/embedded_image_actions.rb

Instance Method Summary collapse

Instance Method Details

#createObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/simplec/embedded_image_actions.rb', line 9

def create
  @embedded_image = EmbeddedImage.new(embedded_image_params)
  if @embedded_image.save
    respond_to do |format|
      format.json {
        render status: 201, location: @embedded_image.url,
          json: @embedded_image.slice(:id, :asset_name, :asset_url)
      }
    end
  else
    respond_to do |format|
      format.json {
        render status: 422, json: @embedded_image.errors
      }
    end
  end
end