summaryrefslogtreecommitdiff
path: root/app/models/asset.rb
blob: f6526f2cae3ad0d7644de80deccc697e06e75982 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Asset < ActiveRecord::Base
  
  has_many :related_assets, :dependent => :destroy
  has_many :pages, :through => :related_assets

  has_attached_file(
    :upload,
    :path => ":rails_root/public/system/:attachment/:id/:style/:filename",
    :url  => "/system/:attachment/:id/:style/:filename",
    :styles => {
      :medium   => "300x300",
      :thumb    => "100x100",
      :headline => "460x250#"
    }
  )

  scope :images,    -> { where(:upload_content_type => ["image/gif", "image/jpeg", "image/png"]) }
  scope :documents, -> { where(:upload_content_type => ["application/pdf", "text/plain", "text/rtf"]) }
  scope :audio,     -> { where(:upload_content_type => ["audio/mpeg", "audio/x-m4a", "audio/wav", "audio/x-wav"]) }

end