app/controllers/spina/admin/attachments_controller.rb in spina-0.12.0 vs app/controllers/spina/admin/attachments_controller.rb in spina-1.0.0

- old
+ new

@@ -5,36 +5,41 @@ layout "spina/admin/media_library" def index add_breadcrumb I18n.t('spina.website.documents'), spina.admin_attachments_path - @attachments = Attachment.file_attached.sorted - @attachment = Attachment.new + @attachments = Attachment.sorted end def create - @attachment = Attachment.create(attachment_params) + @attachments = params[:attachment][:files].map do |file| + attachment = Attachment.create(attachment_params) + attachment.file.attach(file) + attachment + end end def destroy @attachment = Attachment.find(params[:id]) @attachment.destroy redirect_to spina.admin_attachments_url end 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 + @hidden_field_id = params[:hidden_field_id] + @attachments = Attachment.sorted @attachment = Attachment.new end def insert @attachment = Attachment.find(params[:attachment_id]) + Rails.logger.info "HAHA HA HA #{@attachment.id}" end 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 + @attachments = Attachment.sorted @attachment = Attachment.new end def insert_collection @attachments = Attachment.where(id: params[:attachment_ids])