mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-22 05:50:47 +02:00
Create attachment model and hook it up to todo
An attachment has write permissions on group so that managing attachments work from different users in same group, i.e. user apache and user mail.
This commit is contained in:
parent
5499ac2a03
commit
2bd68fecb7
10 changed files with 121 additions and 39 deletions
20
app/models/attachment.rb
Normal file
20
app/models/attachment.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
class Attachment < ActiveRecord::Base
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue