add attachment model and add paperclip

This commit is contained in:
Reinier Balt 2014-07-03 23:21:39 +02:00
parent 47c686ce8e
commit 8c17578f38
2 changed files with 2 additions and 6 deletions

View file

@ -1,13 +1,9 @@
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
path: ":rails_root/db/assets/#{Rails.env}/:class/:id/:basename.:extension"
do_not_validate_attachment_file_type :file
# validates_attachment_content_type :file, :content_type => ["text/plain"]

View file

@ -25,7 +25,7 @@ class Todo < ActiveRecord::Base
has_many :pending_successors, -> {where('todos.state = ?', 'pending')}, :through => :predecessor_dependencies,
:source => :successor
has_many :attachments, dependent: :destroy
has_many :attachments, dependent: :delete_all
# scopes for states of this todo
scope :active, -> { where state: 'active' }