mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-13 10:54:23 +01:00
make attachments accesible from user model and fix cleaning up attachment on destroy
This commit is contained in:
parent
8d9f07f57b
commit
a28edbd5d6
5 changed files with 40 additions and 7 deletions
|
|
@ -817,14 +817,12 @@ class TodosController < ApplicationController
|
|||
def attachment
|
||||
id = params[:id]
|
||||
filename = params[:filename]
|
||||
attachment = Attachment.where(id: id).first
|
||||
attachment = current_user.attachments.find(id)
|
||||
|
||||
if attachment
|
||||
if attachment.todo.user == current_user
|
||||
send_file(attachment.file.path)
|
||||
else
|
||||
head :forbidden
|
||||
end
|
||||
send_file(attachment.file.path,
|
||||
disposition: 'attachment',
|
||||
type: 'message/rfc822')
|
||||
else
|
||||
head :not_found
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue