Class: Spina::Admin::AttachmentsController

Inherits:
AdminController show all
Defined in:
app/controllers/spina/admin/attachments_controller.rb

Instance Method Summary collapse

Methods inherited from AdminController

#current_admin_path

Instance Method Details

#createObject



14
15
16
# File 'app/controllers/spina/admin/attachments_controller.rb', line 14

def create
  @attachment = Attachment.create(attachment_params)
end

#destroyObject



18
19
20
21
22
# File 'app/controllers/spina/admin/attachments_controller.rb', line 18

def destroy
  @attachment = Attachment.find(params[:id])
  @attachment.destroy
  redirect_to spina.admin_attachments_url
end

#indexObject



8
9
10
11
12
# File 'app/controllers/spina/admin/attachments_controller.rb', line 8

def index
  add_breadcrumb I18n.t('spina.website.documents'), spina.admin_attachments_path
  @attachments = Attachment.file_attached.sorted
  @attachment = Attachment.new
end

#insertObject



30
31
32
# File 'app/controllers/spina/admin/attachments_controller.rb', line 30

def insert
  @attachment = Attachment.find(params[:attachment_id])
end

#insert_collectionObject



40
41
42
# File 'app/controllers/spina/admin/attachments_controller.rb', line 40

def insert_collection
  @attachments = Attachment.where(id: params[:attachment_ids])
end

#selectObject



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

def select
  @selected_attachment_id = Attachment.find_by(id: params[:selected_attachment_id]).try(:id)
  @attachments = Attachment.order_by_ids(@selected_attachment_id).file_attached.sorted
  @attachment = Attachment.new
end

#select_collectionObject



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

def select_collection
  @selected_attachment_ids = Attachment.where(id: params[:selected_attachment_ids]).ids
  @attachments = Attachment.order_by_ids(@selected_attachment_ids).file_attached.sorted
  @attachment = Attachment.new
end