Class: Brightcontent::AttachmentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
# File 'app/controllers/brightcontent/attachments_controller.rb', line 10

def create
  @attachment = Attachment.new(attachment_params)
  if @attachment.save
    render json: @attachment.to_json, status: :created
  else
    render json: @attachment.errors, status: :unprocessable_entity
  end
end

#destroyObject



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

def destroy
  Attachment.destroy params[:id]
  head :no_content
end

#repositionObject



24
25
26
27
# File 'app/controllers/brightcontent/attachments_controller.rb', line 24

def reposition
  Attachment.for_attachable(params[:type], params[:id]).reposition! params[:positions]
  head :no_content
end

#showObject



5
6
7
8
# File 'app/controllers/brightcontent/attachments_controller.rb', line 5

def show
  @attachments = Attachment.for_attachable(params[:type], params[:id])
  render layout: false
end