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



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 10

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

  redirect_to_back_url
end

#destroyObject



42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 42

def destroy
  authorize! :delete, @attachment

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

  redirect_to_back_url
end

#editObject



24
25
26
27
28
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 24

def edit
  authorize! :update, @attachment

  render layout: false
end

#updateObject



30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 30

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

  redirect_to_back_url
end