tracks/app/models/attachment.rb
Matt Rogers 0e21d64890
Convert to ApplicationRecord
Rails 5 requires the use of this superclass for all database backed
model objects now.
2018-11-03 15:57:14 -05:00

20 lines
496 B
Ruby

class Attachment < ApplicationRecord
belongs_to :todo, touch: true
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