mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-13 02:44:22 +01:00
if you run MessageGateway under user mail and Tracks under user apache, you cannot delete attachments from the web ui since the default permissions is read-only. To delete an attachment, you need w permission on the directory containing the attachment
24 lines
635 B
Ruby
24 lines
635 B
Ruby
class Attachment < ActiveRecord::Base
|
|
belongs_to :todo, touch: true
|
|
|
|
# enable write permissions on group, since MessageGateway could be run under different
|
|
# user than Tracks (i.e. apache versus mail)
|
|
|
|
has_attached_file :file,
|
|
url: '/:class/:id/:basename.:extension',
|
|
path: ":rails_root/db/assets/#{Rails.env}/:class/:id/:basename.:extension",
|
|
override_file_permissions: 0660
|
|
|
|
do_not_validate_attachment_file_type :file
|
|
# validates_attachment_content_type :file, :content_type => ["text/plain"]
|
|
|
|
before_destroy :delete_attached_file
|
|
|
|
private
|
|
|
|
def delete_attached_file
|
|
file = nil
|
|
save!
|
|
end
|
|
|
|
end
|