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



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

def create
  @attachments = params[:attachment][:files].map do |file|
    attachment = Attachment.create(attachment_params)
    attachment.file.attach(file)
    attachment
  end
end

#destroyObject



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

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

#indexObject



8
9
10
11
# 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.sorted
end

#insertObject



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

def insert
  @attachment = Attachment.find(params[:attachment_id])
  Rails.logger.info "HAHA HA HA #{@attachment.id}"
end

#insert_collectionObject



45
46
47
# File 'app/controllers/spina/admin/attachments_controller.rb', line 45

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

#selectObject



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

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

#select_collectionObject



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

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