Class: Satis::AttachmentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/satis/attachments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  params[:attachments].each do |file|
    @model.public_send(@attachment_type).attach(file)
  end
  redirect_to request.referer || root_path, notice: "Attachment created successfully."

end

#destroyObject



21
22
23
24
25
26
# File 'app/controllers/satis/attachments_controller.rb', line 21

def destroy
  attachment = @model.public_send(@attachment_type).find_by(id: params[:id])
  attachment&.purge

  redirect_to request.referer || root_path, notice: "Attachment deleted successfully."
end

#indexObject



8
9
10
11
# File 'app/controllers/satis/attachments_controller.rb', line 8

def index
  @attachments = @model.public_send(@attachment_type)
  render json: @attachments
end