mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-22 05:50:47 +02:00
make attachments accesible from user model and fix cleaning up attachment on destroy
This commit is contained in:
parent
e38a7742f0
commit
ed9f429d4a
2 changed files with 2 additions and 2 deletions
|
@ -817,7 +817,7 @@ 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
|
||||
send_file(attachment.file.path,
|
||||
|
|
|
@ -25,7 +25,7 @@ class Todo < ActiveRecord::Base
|
|||
has_many :pending_successors, -> {where('todos.state = ?', 'pending')}, :through => :predecessor_dependencies,
|
||||
:source => :successor
|
||||
|
||||
has_many :attachments, dependent: :delete_all
|
||||
has_many :attachments, dependent: :destroy
|
||||
|
||||
# scopes for states of this todo
|
||||
scope :active, -> { where state: 'active' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue