2014-07-03 23:21:39 +02:00
|
|
|
class Attachment < ActiveRecord::Base
|
|
|
|
|
belongs_to :todo, touch: true
|
|
|
|
|
|
2014-07-24 20:58:11 +02:00
|
|
|
# enable write permissions on group, since MessageGateway could be run under different
|
|
|
|
|
# user than Tracks (i.e. apache versus mail)
|
|
|
|
|
|
2014-07-03 23:21:39 +02:00
|
|
|
has_attached_file :file,
|
|
|
|
|
url: '/:class/:id/:basename.:extension',
|
2014-07-24 20:58:11 +02:00
|
|
|
path: ":rails_root/db/assets/#{Rails.env}/:class/:id/:basename.:extension",
|
|
|
|
|
override_file_permissions: 0660
|
2014-07-03 23:21:39 +02:00
|
|
|
|
|
|
|
|
do_not_validate_attachment_file_type :file
|
|
|
|
|
# validates_attachment_content_type :file, :content_type => ["text/plain"]
|
2014-07-17 12:55:30 +02:00
|
|
|
|
|
|
|
|
before_destroy :delete_attached_file
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def delete_attached_file
|
|
|
|
|
file = nil
|
|
|
|
|
save!
|
|
|
|
|
end
|
2014-07-03 23:21:39 +02:00
|
|
|
end
|