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

#filters_jar, #scope

Instance Method Details

#createObject



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

def create
  @attachment = scope.new(attachment_params_for_create)

  authorize @attachment, :create?

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

  render_list
end

#destroyObject



52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 52

def destroy
  authorize @attachment, :delete?

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

  render_list
end

#editObject



34
35
36
37
38
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 34

def edit
  authorize @attachment, :update?

  render_list
end

#indexObject



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

def index
  @attachable = find_attachable_from_params

  authorize @attachable, :read?

  render_list
end

#updateObject



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

def update
  authorize @attachment, :update?

  if @attachment.update(attachment_params_for_update)
    notify_attachable(:update)
  else
    flash.now[:alert] = t("messages.attachments.update_error")
  end

  render_list
end