summaryrefslogtreecommitdiff
path: root/app/models/asset.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/asset.rb')
-rw-r--r--app/models/asset.rb43
1 files changed, 8 insertions, 35 deletions
diff --git a/app/models/asset.rb b/app/models/asset.rb
index 5bfea764..aca0ee80 100644
--- a/app/models/asset.rb
+++ b/app/models/asset.rb
@@ -1,39 +1,12 @@
1class Asset < ActiveRecord::Base 1class Asset < ApplicationRecord
2
3 include FileAttachment
2 4
3 has_many :related_assets, :dependent => :destroy 5 has_many :related_assets, :dependent => :destroy
4 has_many :pages, :through => :related_assets 6 has_many :pages, :through => :related_assets
5 7
6 has_attached_file( 8 scope :images, -> { where(:upload_content_type => ["image/gif", "image/jpeg", "image/png", "image/webp"]) }
7 :upload, 9 scope :documents, -> { where(:upload_content_type => ["application/pdf", "text/plain", "text/rtf"]) }
8 :styles => { 10 scope :audio, -> { where(:upload_content_type => ["audio/mpeg", "audio/x-m4a", "audio/wav", "audio/x-wav"]) }
9 :medium => "300x300", 11
10 :thumb => "100x100",
11 :headline => "460x250#"
12 }
13 )
14
15 named_scope :images, :conditions => {
16 :upload_content_type => [
17 "image/gif",
18 "image/jpeg",
19 "image/png"
20 ]
21 }
22
23 named_scope :documents, :conditions => {
24 :upload_content_type => [
25 "application/pdf",
26 "text/plain",
27 "text/rtf"
28 ]
29 }
30
31 named_scope :audio, :conditions => {
32 :upload_content_type => [
33 "audio/mpeg",
34 "audio/x-m4a",
35 "audio/wav",
36 "audio/x-wav"
37 ]
38 }
39end 12end