tracks/app/models/attachment.rb
Reinier Balt eb4624ff69 set permissions on attachments so that users in same group can handle the attachments
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
2015-08-04 12:47:31 +02:00

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