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

#scope

Instance Method Details

#createObject



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

def create
  @attachment = scope.new(attachment_params_for_create)

  authorize @attachment, :create?

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

  render_or_redirect
end

#destroyObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/dorsale/alexandrie/attachments_controller.rb', line 57

def destroy
  authorize @attachment, :delete?

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

  render_or_redirect
end

#editObject



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

def edit
  authorize @attachment, :update?

  @attachable = @attachment.attachable

  render :index
end

#indexObject



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

def index
  @attachable = find_attachable
  skip_policy_scope

  authorize @attachable, :read?

  @attachment = scope.new(attachment_params_for_create)
end

#updateObject



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

def update
  authorize @attachment, :update?

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

  render_or_redirect
end