Class: Dorsale::Alexandrie::AttachmentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# 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
    # flash[:notice] = t("messages.attachments.create_ok")
  else
    flash[:alert] = t("messages.attachments.create_error")
  end

  render_or_redirect
end

#destroyObject



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

def destroy
  authorize @attachment, :delete?

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

  render_or_redirect
end

#editObject



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

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



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

def update
  authorize @attachment, :update?

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

  render_or_redirect
end