Sha256: 3fe5a39d29242ff90f7761c1ec3372d6ebe1db1497fcda4ae2abd3db45e8b968

Contents?: true

Size: 756 Bytes

Versions: 4

Compression:

Stored size: 756 Bytes

Contents

class Attachment
  include Mongoid::Document
  include Mongoid::Paperclip

  belongs_to :label
  has_mongoid_attached_file :attach,
      :path  => "#{ActiveMetadata::CONFIG['attachment_base_path']}/:document_id/:label/:counter/:basename.:extension",
      :url  => "#{ActiveMetadata::CONFIG['attachment_base_url']}/:document_id/:label/:counter/:basename.:extension"

  field :created_by, :type => Integer
  field :counter, :type => Integer

  Paperclip.interpolates :document_id do |attachment,style|
   attachment.instance.label.active_meta.document_id
  end

  Paperclip.interpolates :label do |attachment,style|
    attachment.instance.label.name
  end

  Paperclip.interpolates :counter do |attachment,style|
    attachment.instance.counter
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_metadata-0.2.2 lib/model/mongoid/attachment.rb
active_metadata-0.2.1 lib/model/mongoid/attachment.rb
active_metadata-0.2.0 lib/model/mongoid/attachment.rb
active_metadata-0.1.9 lib/model/mongoid/attachment.rb