Class: Gaku::AttachmentsController

Inherits:
GakuController show all
Includes:
PolyController
Defined in:
app/controllers/gaku/attachments_controller.rb

Instance Method Summary collapse

Methods inherited from GakuController

#resolve_layout

Instance Method Details

#createObject



16
17
18
19
20
# File 'app/controllers/gaku/attachments_controller.rb', line 16

def create
  @attachment = @attachable.attachments.create(attachment_params)
  set_count
  respond_with @attachment
end

#destroyObject



33
34
35
36
# File 'app/controllers/gaku/attachments_controller.rb', line 33

def destroy
  @attachment.destroy!
  respond_with @attachment
end

#downloadObject



43
44
45
46
# File 'app/controllers/gaku/attachments_controller.rb', line 43

def download
  @attachment = Attachment.find(params[:id])
  send_file @attachment.asset.path
end

#editObject



22
23
24
# File 'app/controllers/gaku/attachments_controller.rb', line 22

def edit
  respond_with @attachment
end

#newObject



11
12
13
14
# File 'app/controllers/gaku/attachments_controller.rb', line 11

def new
  @attachment = @attachable.attachments.new
  respond_with @attachment
end

#recoveryObject



48
49
50
51
# File 'app/controllers/gaku/attachments_controller.rb', line 48

def recovery
  @attachment.recover
  respond_with @attachment
end

#soft_deleteObject



38
39
40
41
# File 'app/controllers/gaku/attachments_controller.rb', line 38

def soft_delete
  @attachment.soft_delete
  respond_with @attachment
end

#updateObject



26
27
28
29
30
31
# File 'app/controllers/gaku/attachments_controller.rb', line 26

def update
  @attachment.update(attachment_params)
  respond_with(@attachment) do |format|
    format.html { redirect_to :back }
  end
end