Sha256: 7cd5aa96e75fd76afa867ba00854ec430c9e8e4bc431485a6f7c02a9e8a8f099
Contents?: true
Size: 847 Bytes
Versions: 3
Compression:
Stored size: 847 Bytes
Contents
class Asset < ApplicationRecord include Concerns::Taggable mount_uploader :filename, AssetUploader has_many :images, dependent: :destroy has_many :content_pictures, dependent: :destroy has_many :attachments, dependent: :destroy scope :image, -> { where(content_type: %w(image/gif image/jpeg image/png)) } before_save :update_filesize, :update_content_type validates :filename, presence: true def image? content_type.to_s.include?('image') end def image Udongo::Assets::Resizer.new(self) if image? end def actual_filename read_attribute(:filename) end def deletable? images.empty? && content_pictures.empty? && attachments.empty? end private def update_filesize self.filesize = filename.size end def update_content_type self.content_type = filename.content_type end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
udongo-7.6.2 | app/models/asset.rb |
udongo-7.6.1 | app/models/asset.rb |
udongo-7.6.0 | app/models/asset.rb |