attachment new version

This commit is contained in:
Andreas Stephanides
2015-04-07 23:21:33 +02:00
parent b04b23e647
commit 0df5e72e15
17 changed files with 273 additions and 43 deletions

View File

@@ -12,11 +12,13 @@
class Attachment < ActiveRecord::Base
has_paper_trail
attr_accessible :name, :datei, :datei_cache,:flag_titlepic
attr_accessible :name, :datei, :datei_cache,:flag_titlepic,:parent_id, :parent_type
belongs_to :thema
mount_uploader :datei, AttachmentUploader
validates :thema, :presence => true
# validates :thema, :presence => true
validates :name, :presence => true
scope :titlepic, ->{where(flag_titlepic: true)}
default_scope order("LOWER(name)")
belongs_to :parent, :polymorphic=>true
def image?
@@ -24,6 +26,9 @@ class Attachment < ActiveRecord::Base
# %w(jpg png jpeg).include?(data_ext)
datei.image?(datei.file)
end
def self.parent_attachment_list_id(parent)
"attachments_for_"+parent.class.to_s+"_"+parent.id.to_s
end
def to_jq_upload
{