Class: Spina::Admin::AttachmentsController
- Inherits:
-
AdminController
- Object
- ActionController::Base
- Spina::ApplicationController
- AdminController
- Spina::Admin::AttachmentsController
- Defined in:
- app/controllers/spina/admin/attachments_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #insert ⇒ Object
- #insert_collection ⇒ Object
- #select ⇒ Object
- #select_collection ⇒ Object
Methods inherited from AdminController
Instance Method Details
#create ⇒ Object
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.create() .file.attach(file) end end |
#destroy ⇒ Object
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. end |
#index ⇒ Object
8 9 10 11 |
# File 'app/controllers/spina/admin/attachments_controller.rb', line 8 def index I18n.t('spina.website.documents'), spina. @attachments = Attachment.sorted end |
#insert ⇒ Object
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_collection ⇒ Object
45 46 47 |
# File 'app/controllers/spina/admin/attachments_controller.rb', line 45 def insert_collection @attachments = Attachment.where(id: params[:attachment_ids]) end |
#select ⇒ Object
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_collection ⇒ Object
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 |