Class: Dorsale::Alexandrie::AttachmentsController

Inherits:
Dorsale::ApplicationController show all
Defined in:
app/controllers/dorsale/alexandrie/attachments_controller.rb

Instance Method Summary collapse

Methods inherited from Dorsale::ApplicationController

#current_user_scope

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 18

def create
  @attachment = ::Dorsale::Alexandrie::Attachment.new(attachment_params_for_create)

  authorize! :create, @attachment

  if @attachment.save
    flash[:notice] = t("messages.attachments.create_ok")
  else
    flash[:alert] = t("messages.attachments.create_error")
  end

  render_or_redirect
end

#destroyObject



48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 48

def destroy
  authorize! :delete, @attachment

  if @attachment.destroy
    flash[:notice] = t("messages.attachments.delete_ok")
  else
    flash[:alert] = t("messages.attachments.delete_error")
  end

  render_or_redirect
end

#editObject



32
33
34
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 32

def edit
  authorize! :update, @attachment
end

#indexObject



12
13
14
15
16
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 12

def index
  @attachable = find_attachable

  authorize! :read, @attachable
end

#updateObject



36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 36

def update
  authorize! :update, @attachment

  if @attachment.update_attributes(attachment_params_for_update)
    flash[:notice] = t("messages.attachments.update_ok")
  else
    flash[:alert] = t("messages.attachments.update_error")
  end

  render_or_redirect
end