mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-17 12:48:08 +01:00
add attachment model and add paperclip
This commit is contained in:
parent
013b260a1b
commit
76de5bf2b3
8 changed files with 78 additions and 22 deletions
10
app/models/attachment.rb
Normal file
10
app/models/attachment.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
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"
|
||||
|
||||
do_not_validate_attachment_file_type :file
|
||||
# validates_attachment_content_type :file, :content_type => ["text/plain"]
|
||||
end
|
||||
|
|
@ -25,6 +25,8 @@ class Todo < ActiveRecord::Base
|
|||
has_many :pending_successors, -> {where('todos.state = ?', 'pending')}, :through => :predecessor_dependencies,
|
||||
:source => :successor
|
||||
|
||||
has_many :attachments, dependent: :delete_all
|
||||
|
||||
# scopes for states of this todo
|
||||
scope :active, -> { where state: 'active' }
|
||||
scope :active_or_hidden, -> { where "todos.state = ? OR todos.state = ?", 'active', 'project_hidden' }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue