diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-27 22:52:50 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-27 22:52:50 +0200 |
| commit | 9a19a0494ef51cdac9a78e24d517ca48ba44c453 (patch) | |
| tree | 8eaae12d8047a40e29d3ea7ff3116b5c869e04bd /app/models/asset.rb | |
| parent | 85a01e35274b8d4d4165a7b26bd7986e211246bb (diff) | |
| parent | 1853082fcd8c067390c246f9daa01a9b47387497 (diff) | |
Migration from Rails 2.3.5 to Rails 8.1 successful.
Merging dev branch.
Diffstat (limited to 'app/models/asset.rb')
| -rw-r--r-- | app/models/asset.rb | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/app/models/asset.rb b/app/models/asset.rb index 5bfea76..aca0ee8 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb | |||
| @@ -1,39 +1,12 @@ | |||
| 1 | class Asset < ActiveRecord::Base | 1 | class 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 | } | ||
| 39 | end | 12 | end |
