From c49296e8430943346289b70f75fb5253d2f4e64f Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Sun, 6 Jul 2014 22:29:19 +0200 Subject: [PATCH] wire up downloading attachments from todo partial --- app/controllers/todos_controller.rb | 2 +- app/helpers/todos_helper.rb | 8 ++++++++ config/routes.rb | 1 - 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index c8276a4a..c7e1c285 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -819,7 +819,7 @@ class TodosController < ApplicationController filename = params[:filename] attachment = current_user.attachments.find(id) - if attachment + if attachment send_file(attachment.file.path, disposition: 'attachment', type: 'message/rfc822') diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 7bec8b48..bdd9e17c 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -212,6 +212,14 @@ module TodosHelper ) end + def attachment_image(todo) + link_to( + image_tag('blank.png', width: 16, height: 16, border:0), + todo.attachments.first.file.url, + {:class => 'todo_attachment', title: 'Get attachments of this todo'} + ) + end + def collapsed_notes_image(todo) link = link_to( image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ), diff --git a/config/routes.rb b/config/routes.rb index 71b5b1e4..02cdb3de 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -90,7 +90,6 @@ Rails.application.routes.draw do get 'convert_to_project' # TODO: convert to PUT/POST delete 'remove_predecessor' # TODO: convert to PUT/POST post 'change_context' - get 'attachment' end collection do get 'done'